docs: update readme and demo
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user