37 lines
942 B
Lua
Raw Normal View History

2023-01-09 21:30:16 +08:00
local type_check = require("Trans.util.debug").type_check
2023-01-09 23:20:56 +08:00
local function format(items, interval)
end
2023-01-09 21:30:16 +08:00
local function process (opts)
type_check {
2023-01-09 23:20:56 +08:00
opts = { opts, 'table' },
['opts.field'] = { opts.field, 'table' },
['opts.order'] = { opts.order, 'table' },
['opts.win'] = { opts.win, 'table' },
['opts.engine'] = { opts.engine, 'table' },
2023-01-09 21:30:16 +08:00
}
2023-01-09 23:20:56 +08:00
2023-01-09 21:30:16 +08:00
local content = require('Trans.component.content'):new()
for _, v in ipairs(opts.order) do
2023-01-09 23:20:56 +08:00
local items = format(require("Trans.component." .. opts.engine .. '.' .. v), 4)
content:insert(items)
2023-01-09 21:30:16 +08:00
end
2023-01-09 23:20:56 +08:00
local lines, __highlight = content:data()
vim.api.nvim_buf_set_lines(opts.bufnr, 0, lines)
for line, l_hl in ipairs(__highlight) do
for _, hl in ipairs(l_hl) do
vim.api.nvim_buf_add_highlight(opts.bufnr, line, hl.name, hl._start, hl._end)
end
end
2023-01-09 21:30:16 +08:00
end
return process