fix: adjust more to make it backward compatible for 0.11-

This commit is contained in:
27Onion Nebell
2025-04-12 12:26:40 +08:00
parent 5779c6f6a7
commit 1460136dd0
6 changed files with 66 additions and 14 deletions

View File

@@ -29,7 +29,14 @@ function M.hovers(bufnr, nodes)
for line, node in ipairs(nodes) do
if node.hovered then
-- stylua: ignore start
vim.hl.range(bufnr, M.ns.hover, 'OutlineCurrent', { line - 1, node.prefix_length }, { line - 1, -1 })
if _G._outline_nvim_has[11] then
vim.hl.range(bufnr, M.ns.hover, 'OutlineCurrent', { line - 1, node.prefix_length }, { line - 1, -1 })
else
---@diagnostic disable-next-line:deprecated
vim.api.nvim_buf_add_highlight(
bufnr, M.ns.hover, 'OutlineCurrent', line - 1, node.prefix_length, -1
)
end
-- stylua: ignore end
end
end
@@ -41,7 +48,14 @@ end
function M.items(bufnr, hl_list)
for _, h in ipairs(hl_list) do
-- stylua: ignore start
vim.hl.range(bufnr, M.ns.items, h.name, { h.line - 1, h.from }, { h.line - 1, h.to })
if _G._outline_nvim_has[11] then
vim.hl.range(bufnr, M.ns.items, h.name, { h.line - 1, h.from }, { h.line - 1, h.to })
else
---@diagnostic disable-next-line:deprecated
vim.api.nvim_buf_add_highlight(
bufnr, M.ns.items, h.name, h.line - 1, h.from, h.to
)
end
-- stylua: ignore end
end
end