File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11local dim = {}
22local util = {}
33
4- local highlighter = require (" vim.treesitter.highlighter" )
5- local ts_utils = require (" nvim-treesitter.ts_utils" )
4+ local ts = vim .treesitter
5+ local ok , ts_utils = pcall (require , " nvim-treesitter.ts_utils" )
6+
7+ local ts_highlighter = ts .highlighter
8+ --- @type (fun ( node : TSNode , line : integer , col : integer ): boolean ) | false
9+ local ts_is_in_node_range = ts .is_in_node_range or (ok and ts_utils .is_in_node_range )
610
711---- --------------------
812-- ## UTIL FUNCTIONS ##--
@@ -85,7 +89,7 @@ function util.get_treesitter_hl(row, col)
8589 end , matches )
8690 end
8791
88- local self = highlighter .active [buf ]
92+ local self = ts_highlighter .active [buf ]
8993 if not self then
9094 return {}
9195 end
@@ -115,7 +119,7 @@ function util.get_treesitter_hl(row, col)
115119 for capture , node , _ in iter do
116120 local hl = query .hl_cache [capture ]
117121
118- if hl and ts_utils . is_in_node_range (node , row , col ) then
122+ if hl and ts_is_in_node_range and ts_is_in_node_range (node , row , col ) then
119123 local c = query ._query .captures [capture ] -- name of the capture in the query
120124 if c ~= nil then
121125 local general_hl = query :_get_hl_from_capture (capture )
You can’t perform that action at this time.
0 commit comments