chore: use conf.theme instead of conf.style.theme

This commit is contained in:
JuanZoran
2023-03-15 19:27:21 +08:00
parent 52238cb1e7
commit 21351b3a26
6 changed files with 92 additions and 91 deletions

View File

@@ -7,7 +7,6 @@ if vim.fn.has('nvim-0.9') == 1 then
}
end
---@class Trans
---@field conf TransConf
@@ -16,9 +15,11 @@ end
return {
---@type string the directory for database file and password file
dir = os.getenv('HOME') .. '/.vim/dict',
---@type table modeStrategy default strategy for mode
query = 'fallback',
---@type 'default' | 'dracula' | 'tokyonight' global Trans theme [see lua/Trans/style/theme.lua]
theme = 'default', -- default | tokyonight | dracula
strategy = {
---@type { frontend:string, backend:string } fallback strategy for mode
---@type { frontend:string, backend:string | string[] } fallback strategy for mode
default = {
frontend = 'hover',
backend = '*',
@@ -26,9 +27,8 @@ return {
},
---@type table<string, TransBackendOpts> fallback backend for mode
backend = {
---@class TransBackendOpts
---@class TransBackendOpts -- TODO :More core options
default = {
---@type integer timeout for backend send request
timeout = 2000,
},
},
@@ -57,16 +57,16 @@ return {
---@type string -- see: /lua/Trans/style/spinner
spinner = 'dots',
---@type string -- TODO :support replace with {{special word}}
fallback_message = '翻译超时或没有找到相关的翻译',
fallback_message = '{{notfound}} 翻译超时或没有找到相关的翻译',
auto_resize = true,
padding = 10, -- padding for hover window width
keymaps = {
-- play = '_', -- Deprecated
pageup = '[[',
pagedown = ']]',
pin = '<leader>[',
close = '<leader>]',
toggle_entry = '<leader>;',
-- play = '_', -- Deprecated
},
---@type string[] auto close events
auto_close_events = {
@@ -94,10 +94,6 @@ return {
},
},
},
style = {
---@type string global Trans theme [see lua/Trans/style/theme.lua]
theme = 'default', -- default | tokyonight | dracula
},
}

View File

@@ -60,7 +60,7 @@ end
local function define_highlights(conf)
local set_hl = vim.api.nvim_set_hl
local highlights = Trans.style.theme[conf.style.theme]
local highlights = Trans.style.theme[conf.theme]
for hl, opt in pairs(highlights) do
set_hl(0, hl, opt)
end

View File

@@ -22,6 +22,8 @@ local function do_query(data)
---@type TransFrontend
local frontend = data.frontend
local result = data.result
for _, backend in ipairs(data.backends) do
---@cast backend TransBackend
local name = backend.name
@@ -40,7 +42,6 @@ local function do_query(data)
result[name] = nil
end
end
end