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

@@ -38,7 +38,14 @@ function M.flash_highlight(winnr, lnum, durationMs, hl_group)
durationMs = 400
end
local bufnr = vim.api.nvim_win_get_buf(winnr)
local ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
local ns
if _G._outline_nvim_has[11] then
ns = vim.api.nvim_create_namespace("_outline_nvim_flash")
vim.hl.range(bufnr, ns, hl_group, { lnum-1, 0 }, { lnum-1, -1 })
else
---@diagnostic disable-next-line:deprecated
ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
end
local remove_highlight = function()
pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns, 0, -1)
end