refactor: change default dict dir to plugin dir/extra, change Trans.json style

This commit is contained in:
JuanZoran
2023-03-23 14:56:48 +08:00
parent 84e06a268e
commit 6def81f2c6
9 changed files with 58 additions and 54 deletions

View File

@ -1,17 +1,21 @@
local Trans = require("Trans")
local db = require("sqlite.db")
local path = Trans.conf.dir .. Trans.separator .. "ultimate.db"
local dict = db:open(path)
local db_name = "stardict"
vim.api.nvim_create_autocmd("VimLeavePre", {
callback = function()
if db:isopen() then db:close() end
end,
})
---@class TransOfflineBackend
local M = {
name = "offline",
no_wait = true,
}
local db = require("sqlite.db")
vim.api.nvim_create_autocmd("VimLeavePre", {
once = true,
callback = function()
if db:isopen() then db:close() end
end,
})
---@param data any
---@return any
---@overload fun(TransData): TransResult
@ -20,10 +24,6 @@ function M.query(data)
return
end
local path = require("Trans").conf.dir .. "/ultimate.db"
local dict = db:open(path)
local db_name = data.db_name or "stardict"
local res = dict:select(db_name, {
where = { word = data.str },
keys = M.query_field,