mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 10:50:06 -04:00
Lua: improve scope queries
- Set scope to parent - Group all scopes - Use the . operator
This commit is contained in:
parent
83c3b4ad75
commit
e5319aa9aa
1 changed files with 12 additions and 12 deletions
|
|
@ -15,28 +15,28 @@
|
||||||
(identifier) @definition.var))
|
(identifier) @definition.var))
|
||||||
|
|
||||||
;; Function definitions
|
;; Function definitions
|
||||||
;; Functions definitions creates both a definition and a new scope
|
|
||||||
((function
|
((function
|
||||||
(function_name
|
(function_name
|
||||||
(function_name_field
|
(function_name_field
|
||||||
(identifier) @definition.associated
|
(identifier) @definition.associated . (property_identifier) @definition.method)))
|
||||||
(property_identifier) @definition.method))) @scope)
|
(#set! definition.method.scope "parent"))
|
||||||
|
|
||||||
((function
|
((function
|
||||||
(function_name (identifier) @definition.function)) @scope)
|
(function_name (identifier) @definition.function))
|
||||||
|
(#set! definition.function.scope "parent"))
|
||||||
|
|
||||||
|
((local_function (identifier) @definition.function)
|
||||||
|
(#set! definition.function.scope "parent"))
|
||||||
|
|
||||||
((local_function
|
|
||||||
(identifier) @definition.function) @scope)
|
|
||||||
[
|
|
||||||
(local_variable_declaration
|
(local_variable_declaration
|
||||||
(variable_declarator
|
(variable_declarator (identifier) @definition.function) . (function_definition))
|
||||||
(identifier) @definition.function)
|
|
||||||
(function_definition) @scope)
|
|
||||||
(function_definition) @scope
|
|
||||||
]
|
|
||||||
|
|
||||||
|
;; Scopes
|
||||||
[
|
[
|
||||||
(program)
|
(program)
|
||||||
|
(function)
|
||||||
|
(local_function)
|
||||||
|
(function_definition)
|
||||||
(if_statement)
|
(if_statement)
|
||||||
(for_in_statement)
|
(for_in_statement)
|
||||||
(repeat_statement)
|
(repeat_statement)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue