Skip to content

Commit a4386a1

Browse files
committed
chore: resolve deprecated in 0.11
1 parent f379c74 commit a4386a1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/nvim-tree/appearance/hi-test.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ local Class = require("nvim-tree.classic")
55
-- others with name and links less than this arbitrary value are short
66
local SHORT_LEN = 50
77

8+
local namespace_hi_test_id = vim.api.nvim_create_namespace("NvimTreeHiTest")
9+
810
---@class (exact) HighlightDisplay: Class for :NvimTreeHiTest
911
---@field group string nvim-tree highlight group name
1012
---@field links string link chain to a concretely defined group
@@ -52,7 +54,12 @@ function HighlightDisplay:render(bufnr, fmt, l)
5254
local text = string.format(fmt, self.group, self.links, self.def)
5355

5456
vim.api.nvim_buf_set_lines(bufnr, l, -1, true, { text })
55-
vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, #self.group)
57+
58+
if vim.fn.has("nvim-0.11") == 1 then
59+
vim.hl.range(bufnr, namespace_hi_test_id, self.group, { l, 0 }, { l, #self.group, }, {})
60+
else
61+
vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, #self.group) ---@diagnostic disable-line: deprecated
62+
end
5663

5764
return l + 1
5865
end

0 commit comments

Comments
 (0)