chore: remove useless code
This commit is contained in:
parent
156e03306a
commit
854bce7b5a
@ -2,7 +2,7 @@ local api, fn = vim.api, vim.fn
|
|||||||
|
|
||||||
---@class TransBuffer
|
---@class TransBuffer
|
||||||
---@field bufnr integer buffer handle
|
---@field bufnr integer buffer handle
|
||||||
---@field [number] string|TransNode|TransNode[] buffer[line] content
|
---@field [integer] string|TransNode|TransNode[] buffer[line] content
|
||||||
local buffer = {}
|
local buffer = {}
|
||||||
|
|
||||||
-- INFO : corountine can't invoke C function
|
-- INFO : corountine can't invoke C function
|
||||||
|
@ -4,9 +4,9 @@ local util = require 'Trans'.util
|
|||||||
---@field [1] string text to be rendered
|
---@field [1] string text to be rendered
|
||||||
---@field render fun(self: TransNode, buffer: TransBuffer, line: number, col: number) render the node
|
---@field render fun(self: TransNode, buffer: TransBuffer, line: number, col: number) render the node
|
||||||
|
|
||||||
|
local item = (function()
|
||||||
---@class TransItem : TransNode
|
---@class TransItem : TransNode
|
||||||
local item_meta = {
|
local mt = {
|
||||||
---@param self TransItem
|
---@param self TransItem
|
||||||
---@param buffer TransBuffer
|
---@param buffer TransBuffer
|
||||||
---@param line integer
|
---@param line integer
|
||||||
@ -16,12 +16,23 @@ local item_meta = {
|
|||||||
buffer:add_highlight(line, self[2], col, col + #self[1])
|
buffer:add_highlight(line, self[2], col, col + #self[1])
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
mt.__index = mt
|
||||||
|
|
||||||
---@class TransText : TransNode
|
---Basic item node
|
||||||
---@field step string
|
---@param tuple {[1]: string, [2]: string?}
|
||||||
---@field nodes TransNode[]
|
---@return TransItem
|
||||||
local text_meta = {
|
return function(tuple)
|
||||||
|
return setmetatable(tuple, mt)
|
||||||
|
end
|
||||||
|
end)()
|
||||||
|
|
||||||
|
local text = (function()
|
||||||
|
---@class TransText : TransNode
|
||||||
|
---@field step string
|
||||||
|
---@field nodes TransNode[]
|
||||||
|
|
||||||
|
local mt = {
|
||||||
---@param self TransText
|
---@param self TransText
|
||||||
---@param buffer TransBuffer
|
---@param buffer TransBuffer
|
||||||
---@param line integer
|
---@param line integer
|
||||||
@ -36,30 +47,20 @@ local text_meta = {
|
|||||||
col = col + #node[1] + len
|
col = col + #node[1] + len
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
item_meta.__index = item_meta
|
mt.__index = mt
|
||||||
text_meta.__index = text_meta
|
|
||||||
|
|
||||||
|
---@param nodes {[number]: TransNode, step: string?}
|
||||||
---Basic item node
|
---@return TransText
|
||||||
---@param tuple {[1]: string, [2]: string?}
|
return function(nodes)
|
||||||
---@return TransItem
|
|
||||||
local function item(tuple)
|
|
||||||
return setmetatable(tuple, item_meta)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@param nodes {[number]: TransNode, step: string?}
|
|
||||||
---@return TransText
|
|
||||||
local function text(nodes)
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
[1] = table.concat(util.list_fields(nodes, 1), nodes.step),
|
[1] = table.concat(util.list_fields(nodes, 1), nodes.step),
|
||||||
step = nodes.step,
|
step = nodes.step,
|
||||||
nodes = nodes,
|
nodes = nodes,
|
||||||
}, text_meta)
|
}, mt)
|
||||||
end
|
end
|
||||||
|
end)()
|
||||||
|
|
||||||
|
|
||||||
---@param args {[number]: TransNode, width: integer, spin: string?}
|
---@param args {[number]: TransNode, width: integer, spin: string?}
|
||||||
@ -85,7 +86,6 @@ end
|
|||||||
---@class TransUtil
|
---@class TransUtil
|
||||||
---@field node TransNodes
|
---@field node TransNodes
|
||||||
|
|
||||||
|
|
||||||
---@class TransNodes
|
---@class TransNodes
|
||||||
return {
|
return {
|
||||||
item = item,
|
item = item,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user