fix: fix plugin_dir and use left slash as path separator for windows
Fixes #46
This commit is contained in:
parent
4b9e8a7ab9
commit
863213bbc8
lua/Trans
@ -1,7 +1,7 @@
|
||||
local Trans = require 'Trans'
|
||||
|
||||
local db = require 'sqlite.db'
|
||||
local path = Trans.conf.dir .. Trans.separator .. 'ultimate.db'
|
||||
local path = Trans.conf.dir .. '/ultimate.db'
|
||||
local dict = db:open(path)
|
||||
local db_name = 'stardict'
|
||||
vim.api.nvim_create_autocmd('VimLeavePre', {
|
||||
|
@ -5,7 +5,7 @@ return function()
|
||||
local fn = vim.fn
|
||||
-- INFO :Check ultimate.db exists
|
||||
local dir = Trans.conf.dir
|
||||
local path = dir .. 'ultimate.db'
|
||||
local path = dir .. '/ultimate.db'
|
||||
|
||||
if fn.isdirectory(dir) == 0 then
|
||||
fn.mkdir(dir, 'p')
|
||||
@ -18,7 +18,7 @@ return function()
|
||||
|
||||
-- INFO :Download ultimate.db
|
||||
local uri = 'https://github.com/skywind3000/ECDICT-ultimate/releases/download/1.0.0/ecdict-ultimate-sqlite.zip'
|
||||
local zip = dir .. 'ultimate.zip'
|
||||
local zip = dir .. '/ultimate.zip'
|
||||
local continue = fn.filereadable(zip) == 1
|
||||
local handle = function(output)
|
||||
if output.exit == 0 and fn.filereadable(zip) then
|
||||
|
@ -57,7 +57,7 @@ local function check_binary_dependencies()
|
||||
end
|
||||
|
||||
local function check_database()
|
||||
local db_path = Trans.conf.dir .. Trans.separator .. 'ultimate.db'
|
||||
local db_path = Trans.conf.dir .. '/ultimate.db'
|
||||
if fn.filereadable(db_path) == 1 then
|
||||
ok [[ultimate database found ]]
|
||||
else
|
||||
@ -69,7 +69,7 @@ local function check_database()
|
||||
end
|
||||
|
||||
local function check_configure_file()
|
||||
local path = fn.expand(Trans.conf.dir .. Trans.separator .. 'Trans.json')
|
||||
local path = fn.expand(Trans.conf.dir .. '/Trans.json')
|
||||
if not fn.filereadable(path) then
|
||||
warn 'Backend configuration file[%s] not found'
|
||||
end
|
||||
|
@ -25,19 +25,16 @@ local system =
|
||||
uname == 'Linux' and (vim.fn.executable 'termux-api-start' == 1 and 'termux' or 'linux') or
|
||||
error 'Unknown System, Please Report Issue'
|
||||
|
||||
local sep = system == 'win' and '\\\\' or '/'
|
||||
---@class Trans
|
||||
---@field style table @Style module
|
||||
---@field cache table<string, TransData> @Cache for translated data object
|
||||
---@field plugin_dir string @Plugin directory
|
||||
---@field separator string @Path separator
|
||||
---@field system 'mac'|'win'|'termux'|'linux' @Path separator
|
||||
---@field system 'mac'|'win'|'termux'|'linux' @Operating system
|
||||
local M = metatable('core', {
|
||||
cache = {},
|
||||
style = metatable 'style',
|
||||
separator = sep,
|
||||
system = system,
|
||||
plugin_dir = debug.getinfo(1, 'S').source:sub(2):match('(.-)lua' .. sep .. 'Trans'),
|
||||
plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, 'S').source:sub(2), ':p:h:h:h'),
|
||||
})
|
||||
|
||||
M.metatable = metatable
|
||||
|
Loading…
x
Reference in New Issue
Block a user