chore: use conf.theme instead of conf.style.theme
This commit is contained in:
@ -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
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ local strategy = {
|
||||
|
||||
pin = function(hover)
|
||||
if hover.pin then return end
|
||||
hover.pin = true
|
||||
local window = hover.window
|
||||
local width, height = window:width(), window:height()
|
||||
local col = vim.o.columns - width - 3
|
||||
@ -25,7 +26,6 @@ local strategy = {
|
||||
})
|
||||
|
||||
window:set('wrap', true)
|
||||
hover.pin = true
|
||||
end,
|
||||
|
||||
close = function(hover)
|
||||
|
@ -124,7 +124,6 @@ function M:wait(tbl, name, timeout)
|
||||
pause(interval)
|
||||
end
|
||||
|
||||
|
||||
-- FIXME :
|
||||
-- buffer:wipe()
|
||||
-- vim.api.nvim_buf_set_lines(buffer.bufnr, 1, -1, true, {})
|
||||
@ -139,6 +138,7 @@ end
|
||||
---@param result TransResult
|
||||
---@overload fun(result:TransResult)
|
||||
function M:process(data, result)
|
||||
if self.pin then return end
|
||||
-- local node = Trans.util.node
|
||||
-- local it, t, f = node.item, node.text, node.format
|
||||
-- self.buffer:setline(it('hello', 'MoreMsg'))
|
||||
|
Reference in New Issue
Block a user