mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 19:39:53 +10:00
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.
This commit is contained in:
committed by
Christian Clason
parent
bd3b6ec836
commit
1af55bfcf2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user