aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2024-07-28 13:30:33 -0700
committerChristian Clason <c.clason@uni-graz.at>2024-07-29 17:15:46 +0200
commit1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654 (patch)
treecd48dc0520895b0e63af1b3f36706f406344d9bd /runtime/lua/vim
parentbd3b6ec8360e0dd6edfe74c3d0013fd2b98b989e (diff)
downloadrneovim-1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654.tar.gz
rneovim-1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654.tar.bz2
rneovim-1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654.zip
feat(treesitter): allow get_node to return anonymous nodes
Adds a new field `include_anonymous` to the `get_node` options to allow anonymous nodes to be returned.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/treesitter.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index e36aacfd94..4629203138 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -342,6 +342,9 @@ end
---
--- Ignore injected languages (default true)
--- @field ignore_injections boolean?
+---
+--- Include anonymous nodes (default false)
+--- @field include_anonymous boolean?
--- Returns the smallest named node at the given position
---
@@ -388,6 +391,9 @@ function M.get_node(opts)
return
end
+ if opts.include_anonymous then
+ return root_lang_tree:node_for_range(ts_range, opts)
+ end
return root_lang_tree:named_node_for_range(ts_range, opts)
end