style: code format use lua_ls
This commit is contained in:
@ -3,10 +3,10 @@ local api = vim.api
|
||||
---@type table<string, fun(hover: TransHover)>
|
||||
local strategy = {
|
||||
pageup = function(hover)
|
||||
hover.buffer:normal("gg")
|
||||
hover.buffer:normal 'gg'
|
||||
end,
|
||||
pagedown = function(hover)
|
||||
hover.buffer:normal("G")
|
||||
hover.buffer:normal 'G'
|
||||
end,
|
||||
pin = function(hover)
|
||||
if hover.pin then
|
||||
@ -22,10 +22,10 @@ local strategy = {
|
||||
col = col,
|
||||
width = width,
|
||||
height = height,
|
||||
relative = "editor",
|
||||
relative = 'editor',
|
||||
}
|
||||
|
||||
window:set("wrap", true)
|
||||
window:set('wrap', true)
|
||||
end,
|
||||
close = function(hover)
|
||||
hover:destroy()
|
||||
|
@ -1,5 +1,5 @@
|
||||
---@type Trans
|
||||
local Trans = require("Trans")
|
||||
local Trans = require 'Trans'
|
||||
|
||||
-- FIXME :Adjust Window Size
|
||||
|
||||
@ -11,8 +11,8 @@ local Trans = require("Trans")
|
||||
---@field destroy_funcs fun(hover:TransHover)[] @functions to be executed when hover window is closed
|
||||
---@field opts TransHoverOpts @options for hover window
|
||||
---@field pin boolean @whether hover window is pinned
|
||||
local M = Trans.metatable("frontend.hover", {
|
||||
ns = vim.api.nvim_create_namespace("TransHoverWin"),
|
||||
local M = Trans.metatable('frontend.hover', {
|
||||
ns = vim.api.nvim_create_namespace 'TransHoverWin',
|
||||
queue = {},
|
||||
})
|
||||
M.__index = M
|
||||
@ -85,12 +85,12 @@ function M:init_window(opts)
|
||||
title = m_opts.title,
|
||||
width = opts.width or m_opts.width,
|
||||
height = opts.height or m_opts.height,
|
||||
relative = opts.relative or "cursor",
|
||||
relative = opts.relative or 'cursor',
|
||||
}
|
||||
-- stylua: ignore end
|
||||
|
||||
if win_opts.title then
|
||||
win_opts.title_pos = "center"
|
||||
win_opts.title_pos = 'center'
|
||||
end
|
||||
|
||||
option.win_opts = win_opts
|
||||
@ -103,7 +103,7 @@ end
|
||||
---@return string formatted text
|
||||
---@return integer _ replaced count
|
||||
function M:icon_format(format)
|
||||
return format:gsub("{{(%w+)}}", self.opts.icon)
|
||||
return format:gsub('{{(%w+)}}', self.opts.icon)
|
||||
end
|
||||
|
||||
---Get Check function for waiting
|
||||
@ -127,7 +127,7 @@ function M:wait()
|
||||
return function()
|
||||
cur = cur + 1
|
||||
buffer[1] = spinner[cur % size + 1] .. (cell):rep(cur)
|
||||
buffer:add_highlight(1, "TransWaitting")
|
||||
buffer:add_highlight(1, 'TransWaitting')
|
||||
pause(interval)
|
||||
return cur < times
|
||||
end
|
||||
@ -150,14 +150,14 @@ function M:fallback()
|
||||
|
||||
-- TODO :Center
|
||||
buffer[1] = Trans.util.center(fallback_msg, opts.width)
|
||||
buffer:add_highlight(1, "TransFailed")
|
||||
buffer:add_highlight(1, 'TransFailed')
|
||||
self:defer()
|
||||
end
|
||||
|
||||
---Defer function when process done
|
||||
function M:defer()
|
||||
self.window:set("wrap", true)
|
||||
self.buffer:set("modifiable", false)
|
||||
self.window:set('wrap', true)
|
||||
self.buffer:set('modifiable', false)
|
||||
|
||||
local auto_close_events = self.opts.auto_close_events
|
||||
if not auto_close_events then return end
|
||||
@ -191,7 +191,7 @@ function M:process(data)
|
||||
local buffer = self.buffer
|
||||
|
||||
if opts.auto_play then
|
||||
(data.from == "en" and data.str or result.definition[1]):play()
|
||||
(data.from == 'en' and data.str or result.definition[1]):play()
|
||||
end
|
||||
|
||||
-- vim.pretty_print(result)
|
||||
|
@ -1,4 +1,4 @@
|
||||
local node = require('Trans').util.node
|
||||
local node = require 'Trans'.util.node
|
||||
local it, conjunction = node.item, node.conjunction
|
||||
local interval = (' '):rep(4)
|
||||
|
||||
@ -35,7 +35,7 @@ local default = {
|
||||
)
|
||||
end
|
||||
|
||||
buffer:setline('')
|
||||
buffer:setline ''
|
||||
end,
|
||||
definition = function(hover, result)
|
||||
local definition = result.definition
|
||||
@ -50,7 +50,7 @@ local default = {
|
||||
)
|
||||
end
|
||||
|
||||
buffer:setline('')
|
||||
buffer:setline ''
|
||||
end,
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local node = require('Trans').util.node
|
||||
local node = require 'Trans'.util.node
|
||||
local it, t, f, co = node.item, node.text, node.format, node.conjunction
|
||||
local interval = (' '):rep(4)
|
||||
|
||||
@ -26,7 +26,7 @@ function M.title(hover, result)
|
||||
t {
|
||||
it { '[' },
|
||||
it { (phonetic and phonetic ~= '') and phonetic or icon.notfound, 'TransPhonetic' },
|
||||
it { ']' }
|
||||
it { ']' },
|
||||
},
|
||||
|
||||
it { collins and icon.star:rep(collins) or icon.notfound, 'TransCollins' },
|
||||
@ -54,7 +54,7 @@ function M.tag(hover, result)
|
||||
})
|
||||
end
|
||||
|
||||
buffer:setline('')
|
||||
buffer:setline ''
|
||||
end
|
||||
|
||||
function M.exchange(hover, result)
|
||||
@ -70,7 +70,7 @@ function M.exchange(hover, result)
|
||||
)
|
||||
end
|
||||
|
||||
buffer:setline('')
|
||||
buffer:setline ''
|
||||
end
|
||||
|
||||
function M.pos(hover, result)
|
||||
@ -86,7 +86,7 @@ function M.pos(hover, result)
|
||||
)
|
||||
end
|
||||
|
||||
buffer:setline('')
|
||||
buffer:setline ''
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user