Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lua/dim.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
local dim = {}
local util = {}

local highlighter = require("vim.treesitter.highlighter")
local ts_utils = require("nvim-treesitter.ts_utils")
local ts = vim.treesitter
local ok, ts_utils = pcall(require, "nvim-treesitter.ts_utils")

local ts_highlighter = ts.highlighter
---@type (fun(node: TSNode, line: integer, col: integer): boolean) | false
local ts_is_in_node_range = ts.is_in_node_range or (ok and ts_utils.is_in_node_range)

------------------------
--## UTIL FUNCTIONS ##--
Expand Down Expand Up @@ -85,7 +89,7 @@ function util.get_treesitter_hl(row, col)
end, matches)
end

local self = highlighter.active[buf]
local self = ts_highlighter.active[buf]
if not self then
return {}
end
Expand Down Expand Up @@ -115,7 +119,7 @@ function util.get_treesitter_hl(row, col)
for capture, node, _ in iter do
local hl = query.hl_cache[capture]

if hl and ts_utils.is_in_node_range(node, row, col) then
if hl and ts_is_in_node_range and ts_is_in_node_range(node, row, col) then
local c = query._query.captures[capture] -- name of the capture in the query
if c ~= nil then
local general_hl = query:_get_hl_from_capture(capture)
Expand Down