feat: add more bugs

This commit is contained in:
JuanZoran
2023-01-09 21:30:16 +08:00
parent fef956e36d
commit 67c6ffa989
20 changed files with 149 additions and 144 deletions

View File

@@ -1,9 +1,9 @@
local type_check = require("Trans.util.debug").type_check
local window = require("Trans.conf.window")
-- Default conf
local conf = require("Trans.conf.loader").loaded_conf
local core = require("Trasn.core")
local function get_opts(opts)
local default_conf = {
method = vim.api.nvim_get_mode(),
@@ -11,17 +11,28 @@ local function get_opts(opts)
'local',
-- TODO : other engine
},
win = window.cursor_win,
win = {
style = 'cursor',
width = conf.window.cursor.width,
height = conf.window.cursor.height
},
}
-- TODO :process win height and width
if type(opts.engine) == 'string' then
opts.engine = { opts.engine }
end
if opts.win then
opts.win = window.process(opts.win)
local width, height = opts.win.width, opts.win.height
if width and width > 0 and width <= 1 then
opts.win.width = math.floor(vim.o.columns * width)
end
if height and height > 0 and height <= 1 then
opts.win.height = math.floor(vim.o.lines * opts.win.height)
end
end
return vim.tbl_extend('force', default_conf, opts)
end
@@ -29,24 +40,28 @@ local function translate(opts)
type_check {
opts = { opts, 'table' }
}
--- TODO : 异步请求
-- NOTE : 这里只处理了本地的请求
opts = get_opts(opts or {})
local field = core.query(opts)
opts = {
local proc_opts = {
field = field,
order = conf.order['offline'],
engine = 'offline',
win_style = opts.win.style,
}
local content = core.process(opts)
local content, highlight = core.process(proc_opts)
opts = {
style = opts.style,
height = opts.height,
width = opts.width,
local win_opts = {
win = opts.win,
content = content,
highlight = highlight,
}
core.show(opts)
core.show_win(win_opts)
end
return translate