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

@ -30,10 +30,10 @@ end
local all_name = {}
local backend_order = conf.backend_order or vim.tbl_keys(user_conf)
for _, name in ipairs(backend_order) do
if not user_conf[name].disable and user_conf[name] then
all_name[#all_name + 1] = name
for _, config in ipairs(user_conf) do
if not config.disable then
all_name[#all_name + 1] = config.name
user_conf[config.name] = config
end
end

View File

@ -5,13 +5,12 @@
---@class TransConf
return {
---@type string the directory for database file and password file
dir = os.getenv('HOME') .. '/.vim/dict',
query = 'fallback',
debug = true,
dir = require('Trans').relative_path({ 'extra' }, true),
query = 'fallback',
debug = true,
---@type 'default' | 'dracula' | 'tokyonight' global Trans theme [see lua/Trans/style/theme.lua]
theme = 'default', -- default | tokyonight | dracula
backend_order = nil,
strategy = {
theme = 'default', -- default | tokyonight | dracula
strategy = {
---@type { frontend:string, backend:string | string[] } fallback strategy for mode
default = {
frontend = 'hover',
@ -19,7 +18,7 @@ return {
},
},
---@type table frontend options
frontend = {
frontend = {
---@class TransFrontendOpts
---@field keymaps table<string, string>
default = {
@ -128,6 +127,7 @@ return {
-- },
-- },
-- local title = {
-- "████████╗██████╗ █████╗ ███╗ ██╗███████╗",
-- "╚══██╔══╝██╔══██╗██╔══██╗████╗ ██║██╔════╝",

View File

@ -4,7 +4,7 @@ return function()
local Trans = require('Trans')
-- INFO :Check ultimate.db exists
local dir = Trans.conf.dir
local path = dir .. '/ultimate.db'
local path = dir .. 'ultimate.db'
local fn = vim.fn
if fn.isdirectory(dir) == 0 then
@ -20,7 +20,8 @@ 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'
if fn.filereadable(zip) then os.remove(zip) end
local handle = function(output)
@ -43,7 +44,6 @@ return function()
vim.notify(debug_message, vim.log.ERROR)
end
Trans.curl.get(uri, {
output = zip,
callback = handle,
@ -51,6 +51,6 @@ return function()
-- INFO : Install tts dependencies
if fn.has('linux') == 0 and fn.has('mac') == 0 then
os.execute('cd ./tts/ && npm install')
os.execute('cd ./tts && npm install')
end
end

View File

@ -207,7 +207,6 @@ function M.list_concat(list, step)
return ret
end
---Get the field of the list
---@param list any[]
---@param field any
@ -220,6 +219,7 @@ function M.list_fields(list, field)
return ret
end
---@class Trans
---@field util TransUtil
return M