docs: modify readme file

This commit is contained in:
JuanZoran
2023-01-10 23:37:26 +08:00
parent 01f5882b13
commit 17ffaf69c9
4 changed files with 122 additions and 58 deletions

View File

@@ -1,6 +1,6 @@
local M = {}
M.component = function(field)
M.component = function(field, max_size)
if field.translation then
local ref = {
{ '中文翻译', 'TransRef' }
@@ -12,8 +12,13 @@ M.component = function(field)
emptyline = true,
needformat = true,
}
local size = 0
for trans in vim.gsplit(field.translation, '\n', true) do
size = size + 1
table.insert(translations, trans)
if size == max_size then
break
end
end
return { ref, translations }

View File

@@ -4,13 +4,13 @@ M.conf = {
style = {
ui = {
input = 'float',
normal = 'cursor',
select = 'cursor'
n = 'cursor',
v = 'cursor',
},
window = {
cursor = {
border = 'rounded',
width = 50,
width = 40,
height = 50,
},
float = {
@@ -18,14 +18,9 @@ M.conf = {
width = 0.9,
height = 0.8,
},
-- NOTE :如果你想限制某个组件的行数,可以设置 (名称与order相同)
-- Example:
-- limit = {
-- En = 1, -- 只显示第一行,(一般为最广泛的释义)
-- },
limit = nil,
},
},
order = {
offline = {
'Title',
@@ -33,6 +28,7 @@ M.conf = {
'Pos',
'Exchange',
'Translation',
-- NOTE :如果你想限制某个组件的行数可以设置max_size
-- { 'Definition', max_size = 4 },
},
-- online = {

View File

@@ -4,14 +4,13 @@ local core = require("Trans.core")
local function get_opts(opts)
local mode = vim.api.nvim_get_mode().mode
local default_conf = {
method = vim.api.nvim_get_mode().mode,
engine = {
'offline',
-- TODO : other engine
},
method = mode,
engine = conf.base.engine,
win = {
style = 'cursor',
style = conf.style.ui[opts.method or mode],
width = conf.style.window.cursor.width,
height = conf.style.window.cursor.height
},
@@ -36,7 +35,6 @@ local function get_opts(opts)
return vim.tbl_extend('force', default_conf, opts)
end
-- EXAMPLE :
-- require('Trans').translate({
-- method = 'input', -- 不填则自动判断mode获取查询的单词
@@ -85,7 +83,6 @@ local function create_win(win)
return bufnr, winid
end
local function translate(opts)
vim.validate {
opts = { opts, 'table', true }