feat: add some bugs

This commit is contained in:
JuanZoran
2023-01-09 18:57:20 +08:00
parent 32cba43aa2
commit fef956e36d
12 changed files with 125 additions and 65 deletions

View File

@ -79,14 +79,14 @@
```lua
vim.keymap.set('n', 'mi', function ()
require('Trans').translate({
method = 'input',
method = 'input', -- 不填则自动判断mode获取查询的单词
engine = { -- 异步查询所有的引擎, 按照列表
'local',
'youdao',
'baidu'
},
-- view = 'cursor'
view = {
-- win = 'cursor'
win = {
style = 'cursor',
height = 50,
width = 30,

View File

@ -15,6 +15,27 @@ local function get_select()
end
local function get_word(method)
if not method then
local mode = vim.api.nvim_get_mode()
if mode == 'n' then
return vim.fn.expand('<cword>')
elseif mode == 'v' then
return get_select()
else
error('invalid mode')
end
end
if method == 'input' then
return vim.fn.input('请输入您要查询的单词:') -- TODO Use Telescope with fuzzy finder
-- TODO : other method
else
error('invalid method')
end
end
M.get_query_res = function(method)
type_check {
method = { method, 'string' },
@ -25,7 +46,6 @@ M.get_query_res = function(method)
elseif method == 'select' then
word = get_select():match('%S+')
elseif method == 'input' then
word = vim.fn.input('请输入您要查询的单词:') -- TODO Use Telescope with fuzzy finder
else
error('unknown method')
end