aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_comment.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2026-09-28 11:24:21 +0100
committerLewis Russell <me@lewisr.dev>2026-09-28 15:17:58 +0100
commitd49bbcf92e5dc1e96bd09fca62fcf7152c459ba8 (patch)
treead8e8d2ec9fbe8a3e2bf165145627def30467670 /runtime/lua/vim/_comment.lua
parentd51a6e2d55486b8ac3e352dc48f290884577dad9 (diff)
downloadrneovim-d49bbcf92e5dc1e96bd09fca62fcf7152c459ba8.tar.gz
rneovim-d49bbcf92e5dc1e96bd09fca62fcf7152c459ba8.tar.bz2
rneovim-d49bbcf92e5dc1e96bd09fca62fcf7152c459ba8.zip
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
Diffstat (limited to 'runtime/lua/vim/_comment.lua')
-rw-r--r--runtime/lua/vim/_comment.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/_comment.lua b/runtime/lua/vim/_comment.lua
index a3fa08150d..502a4bec64 100644
--- a/runtime/lua/vim/_comment.lua
+++ b/runtime/lua/vim/_comment.lua
@@ -20,7 +20,7 @@ local function get_commentstring(ref_position)
-- Get 'commentstring' from tree-sitter captures' metadata.
-- Traverse backwards to prefer narrower captures.
- local caps = vim.treesitter.get_captures_at_pos(0, row, col)
+ local caps = vim.treesitter.get_captures(0, { row, col })
for i = #caps, 1, -1 do
local id, metadata = caps[i].id, caps[i].metadata
local md_cms = metadata['bo.commentstring'] or metadata[id] and metadata[id]['bo.commentstring']