docs: update readme and demo

This commit is contained in:
JuanZoran
2023-01-21 00:24:58 +08:00
parent 6df43db326
commit f5f135f794
6 changed files with 102 additions and 59 deletions

View File

@@ -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 = {

View File

@@ -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

View File

@@ -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