From d49bbcf92e5dc1e96bd09fca62fcf7152c459ba8 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 28 Sep 2026 11:24:21 +0100 Subject: feat(treesitter): add get_captures() for positions and ranges Problem: get_captures_at_pos() only returns captures at one position. It cannot query a whole line or range. It can also miss captures from injected languages outside the visible area. Solution: Add vim.treesitter.get_captures() with a required start and an optional exclusive stop. Accept row numbers or {row, col} positions. Without a stop, query one position or a whole line. Parse the requested range and return capture coordinates. Deprecate get_captures_at_pos() with a compatibility wrapper and migrate its internal callers. Keep get_captures_at_cursor() for capture names at a window's cursor. AI-assisted --- runtime/lua/vim/_inspector.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/_inspector.lua') diff --git a/runtime/lua/vim/_inspector.lua b/runtime/lua/vim/_inspector.lua index 49a99c4db8..e33f9c8998 100644 --- a/runtime/lua/vim/_inspector.lua +++ b/runtime/lua/vim/_inspector.lua @@ -93,7 +93,7 @@ function vim.inspect_pos(buf, row, col, filter) -- treesitter if filter.treesitter then - for _, capture in pairs(vim.treesitter.get_captures_at_pos(buf, row, col)) do + for _, capture in pairs(vim.treesitter.get_captures(buf, { row, col })) do --- @diagnostic disable-next-line: inject-field capture.hl_group = '@' .. capture.capture .. '.' .. capture.lang results.treesitter[#results.treesitter + 1] = resolve_hl(capture) -- cgit