Skip to content

Commit 334c4a7

Browse files
phanenibhagwan
authored andcommitted
fix: ts highlighter error on master
1 parent 1ee12b7 commit 334c4a7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lua/fzf-lua/win.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function TSInjector.setup()
1717

1818
TSInjector._setup = true
1919
TSInjector._ns = TSInjector._ns or vim.api.nvim_create_namespace("fzf-lua.win.highlighter")
20+
TSInjector._has_on_range = TSInjector._has_on_range == nil
21+
and pcall(vim.api.nvim_set_decoration_provider, TSInjector._ns, { on_range = function() end })
22+
or TSInjector._has_on_range
2023

2124
local function wrap_ts_hl_callback(name)
2225
return function(_, win, buf, ...)
@@ -27,7 +30,9 @@ function TSInjector.setup()
2730
for _, hl in pairs(TSInjector.cache[buf] or {}) do
2831
if hl.enabled then
2932
vim.treesitter.highlighter.active[buf] = hl.highlighter
30-
vim.treesitter.highlighter[name](_, win, buf, ...)
33+
if vim.treesitter.highlighter[name] then
34+
vim.treesitter.highlighter[name](_, win, buf, ...)
35+
end
3136
end
3237
end
3338
vim.treesitter.highlighter.active[buf] = nil
@@ -37,14 +42,16 @@ function TSInjector.setup()
3742
vim.api.nvim_set_decoration_provider(TSInjector._ns, {
3843
on_win = wrap_ts_hl_callback("_on_win"),
3944
on_line = wrap_ts_hl_callback("_on_line"),
45+
on_range = TSInjector._has_on_range and wrap_ts_hl_callback("_on_range") or nil,
4046
})
4147

4248
return true
4349
end
4450

4551
function TSInjector.deregister()
4652
if not TSInjector._ns then return end
47-
vim.api.nvim_set_decoration_provider(TSInjector._ns, { on_win = nil, on_line = nil })
53+
vim.api.nvim_set_decoration_provider(TSInjector._ns,
54+
{ on_win = nil, on_line = nil, on_range = nil })
4855
TSInjector._setup = nil
4956
end
5057

0 commit comments

Comments
 (0)