Skip to content

Commit 1fef581

Browse files
author
Astro
authored
Merge pull request #17 from Gelio/fix-query-capture-breaking-change
fix: use higher-level API to get capture names
2 parents 2e4f0f9 + 3ed4bba commit 1fef581

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/dim.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ end
7777
function util.get_treesitter_hl(row, col)
7878
local buf = vim.api.nvim_get_current_buf()
7979

80+
-- NOTE: use new functionality from https://github.com/neovim/neovim/issues/14090#issuecomment-1228444035
81+
if vim.treesitter.get_captures_at_position ~= nil then
82+
local matches = vim.treesitter.get_captures_at_position(buf, row, col)
83+
return vim.tbl_map(function(match)
84+
return "@" .. match.capture
85+
end, matches)
86+
end
87+
8088
local self = highlighter.active[buf]
8189
if not self then
8290
return {}

0 commit comments

Comments
 (0)