|
1 | 1 | ---Run a test similar to :so $VIMRUNTIME/syntax/hitest.vim
|
2 | 2 | ---Display all icons and their group highlighted, followed by the concrete definition
|
3 |
| --- |
4 |
| ----@class IconDisplay for :NvimTreeHiTest |
| 3 | + |
| 4 | +local namespace_hi_test_id = vim.api.nvim_create_namespace "NvimWebDeviconsHiTest" |
| 5 | + |
| 6 | +---@class (exact) IconDisplay for :NvimTreeHiTest |
5 | 7 | ---@field tag string filename, os or extension
|
6 | 8 | ---@field name string name without prefix
|
7 | 9 | ---@field icon string icon itself
|
8 | 10 | ---@field group string|nil :hi group name
|
9 | 11 | ---@field def string|nil :hi concrete definition
|
| 12 | +---@field private __index IconDisplay? TODO migrate to classic |
10 | 13 | local IconDisplay = {}
|
11 | 14 |
|
12 | 15 | ---@param o IconDisplay
|
@@ -44,7 +47,11 @@ function IconDisplay:render(bufnr, max_tag_len, max_group_len, l)
|
44 | 47 | local text = string.format(fmt, self.icon, self.tag, self.group, self.def)
|
45 | 48 |
|
46 | 49 | vim.api.nvim_buf_set_lines(bufnr, l, -1, true, { text })
|
47 |
| - vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, -1) |
| 50 | + if vim.fn.has "nvim-0.11" == 1 and vim.hl and vim.hl.range then |
| 51 | + vim.hl.range(bufnr, namespace_hi_test_id, self.group, { l, 0 }, { l, -1 }, {}) |
| 52 | + else |
| 53 | + vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, -1) ---@diagnostic disable-line: deprecated |
| 54 | + end |
48 | 55 |
|
49 | 56 | return l + 1
|
50 | 57 | end
|
|
0 commit comments