refactor: add frontend.hover.load function to set buffer content
This commit is contained in:
@ -1,23 +1,20 @@
|
||||
local api = vim.api
|
||||
local add_hl = api.nvim_buf_add_highlight
|
||||
|
||||
local item_meta = {
|
||||
render = function(self, bufnr, line, col)
|
||||
render = function(self, buffer, line, col)
|
||||
if self[2] then
|
||||
add_hl(bufnr, self.ns or -1, self[2], line, col, col + #self[1])
|
||||
buffer:add_highlight(line, self[2], col, col + #self[1])
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
local text_meta = {
|
||||
render = function(self, bufnr, line, col)
|
||||
render = function(self, buffer, line, col)
|
||||
local items = self.items
|
||||
local step = self.step or ''
|
||||
local len = #step
|
||||
|
||||
for i = 1, self.size do
|
||||
local item = items[i]
|
||||
item:render(bufnr, line, col)
|
||||
item:render(buffer, line, col)
|
||||
col = col + #item[1] + len
|
||||
end
|
||||
end
|
||||
@ -28,6 +25,7 @@ text_meta.__index = function(self, key)
|
||||
return text_meta[key] or (key == 1 and table.concat(self.strs, self.step) or nil)
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
item = function(text, highlight)
|
||||
return setmetatable({
|
||||
|
Reference in New Issue
Block a user