fix: add max_size support and definition need better format

This commit is contained in:
JuanZoran
2023-01-10 23:15:31 +08:00
parent 32eeae88d4
commit 01f5882b13
16 changed files with 223 additions and 105 deletions

View File

@@ -10,8 +10,8 @@ M.conf = {
window = {
cursor = {
border = 'rounded',
width = 40,
height = 20,
width = 50,
height = 50,
},
float = {
border = 'rounded',
@@ -33,10 +33,10 @@ M.conf = {
'Pos',
'Exchange',
'Translation',
'Definition',
-- { 'Definition', max_size = 4 },
},
-- online = {
-- -- TODO
-- -- TODO
-- },
},
ui = {
@@ -46,7 +46,7 @@ M.conf = {
bold = true,
},
TransPhonetic = {
fg = '#8b949e',
link = 'Linenr'
},
TransRef = {
fg = '#75beff',
@@ -65,7 +65,8 @@ M.conf = {
link = 'TransWord',
},
TransDefinition = {
fg = '#bc8cff',
-- fg = '#bc8cff',
link = 'Moremsg',
},
TransCursorWin = {
link = 'Normal',
@@ -93,14 +94,14 @@ M.conf = {
auto_close = true,
engine = {
-- TODO
'local',
'offline',
}
},
-- map = {
-- -- TODO
-- },
-- history = {
-- -- TOOD
-- -- TOOD
-- }
-- TODO add online translate engine

View File

@@ -45,16 +45,11 @@ M.load_conf = function(conf)
pre_process()
M.loaded_conf = vim.tbl_deep_extend('force', default_conf, user_conf)
local width = M.loaded_conf.style.window.float.width
local height = M.loaded_conf.style.window.float.height
local win = M.loaded_conf.style.window
assert(win.float.height <= 1 and win.float.height > 0 and win.cursor.height > 1, win.cursor.width > 1)
if width > 0 and width <= 1 then
M.loaded_conf.style.window.float.width = math.floor(width * vim.o.columns)
end
if height > 0 and height <= 1 then
M.loaded_conf.style.window.float.height = math.floor(height * (vim.o.lines - vim.o.cmdheight))
end
win.float.width = math.floor(win.float.width * vim.o.columns)
win.float.height = math.floor(win.float.height * (vim.o.lines - vim.o.cmdheight))
user_conf = nil
default_conf = nil