docs: update readme and demo
This commit is contained in:
@@ -6,7 +6,6 @@ M.conf = {
|
||||
n = 'hover',
|
||||
v = 'hover',
|
||||
},
|
||||
-- animation = true,
|
||||
hover = {
|
||||
width = 36,
|
||||
height = 26,
|
||||
@@ -24,6 +23,8 @@ M.conf = {
|
||||
close = '+',
|
||||
},
|
||||
animation = {
|
||||
-- open = 'fold',
|
||||
-- close = 'fold',
|
||||
open = 'slid',
|
||||
close = 'slid',
|
||||
interval = 12,
|
||||
@@ -42,9 +43,9 @@ M.conf = {
|
||||
quit = 'q',
|
||||
},
|
||||
animation = {
|
||||
open = 'slid',
|
||||
close = 'slid',
|
||||
interval = 8,
|
||||
open = 'fold',
|
||||
close = 'fold',
|
||||
interval = 10,
|
||||
}
|
||||
},
|
||||
order = {
|
||||
@@ -54,8 +55,6 @@ M.conf = {
|
||||
'pos',
|
||||
'exchange',
|
||||
'translation',
|
||||
-- NOTE :如果你想限制某个组件的行数,可以设置max_size
|
||||
-- { 'Definition', max_size = 4 },
|
||||
'definition',
|
||||
-- },
|
||||
-- online = {
|
||||
|
@@ -1,28 +1,44 @@
|
||||
-- local m_window
|
||||
-- local m_result
|
||||
--
|
||||
--
|
||||
-- return function(word)
|
||||
-- -- TODO :online query
|
||||
-- m_result = require('Trans.query.offline')(word)
|
||||
-- m_window = require('Trans.window')
|
||||
-- local float = require('Trans').conf.float
|
||||
--
|
||||
-- local opt = {
|
||||
-- relative = 'editor',
|
||||
-- width = float.width,
|
||||
-- height = float.height,
|
||||
-- border = float.border,
|
||||
-- title = float.title,
|
||||
-- row = math.floor((vim.o.lines - float.height) / 2),
|
||||
-- col = math.floor((vim.o.columns - float.width) / 2),
|
||||
-- }
|
||||
--
|
||||
-- -- 创建窗口
|
||||
-- m_window.init(true, opt)
|
||||
-- m_window.center('https:github.com/JuanZoran/Trans.nvim', '@text.uri') -- only show color with treesiter
|
||||
-- m_window.draw()
|
||||
-- m_window.map('q', function()
|
||||
-- m_window.try_close(float.animation)
|
||||
-- end)
|
||||
-- end
|
||||
local m_window
|
||||
local m_result
|
||||
|
||||
local function set_title()
|
||||
local title = m_window.title
|
||||
local github = 'https://github.com/JuanZoran/Trans.nvim'
|
||||
|
||||
-- TODO :config this
|
||||
title:center_line(github, '@text.uri')
|
||||
end
|
||||
|
||||
local action = {
|
||||
quit = function ()
|
||||
m_window:try_close()
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
return function(word)
|
||||
-- TODO :online query
|
||||
local float = require('Trans').conf.float
|
||||
m_result = require('Trans.query.offline')(word)
|
||||
|
||||
local opt = {
|
||||
relative = 'editor',
|
||||
width = float.width,
|
||||
height = float.height,
|
||||
border = float.border,
|
||||
title = float.title,
|
||||
row = math.floor((vim.o.lines - float.height) / 2),
|
||||
col = math.floor((vim.o.columns - float.width) / 2),
|
||||
}
|
||||
m_window = require('Trans.window')(true, opt)
|
||||
m_window.animation = float.animation
|
||||
|
||||
set_title()
|
||||
m_window:draw()
|
||||
m_window:open()
|
||||
m_window:bufset('bufhidden', 'wipe')
|
||||
|
||||
for act, key in pairs(float.keymap) do
|
||||
m_window:map(key, action[act])
|
||||
end
|
||||
end
|
||||
|
@@ -278,6 +278,7 @@ return function(entry, option)
|
||||
|
||||
win:set('winhl', 'Normal:TransWin,FloatBorder:TransBorder')
|
||||
win:bufset('filetype', 'Trans')
|
||||
win:bufset('buftype', 'nofile')
|
||||
|
||||
---@diagnostic disable-next-line: return-type-mismatch
|
||||
return win
|
||||
|
Reference in New Issue
Block a user