mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 11:36:54 -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))
|
||||
|
||||
;; Function definitions
|
||||
;; Functions definitions creates both a definition and a new scope
|
||||
((function
|
||||
(function_name
|
||||
(function_name_field
|
||||
(identifier) @definition.associated
|
||||
(property_identifier) @definition.method))) @scope)
|
||||
(identifier) @definition.associated . (property_identifier) @definition.method)))
|
||||
(#set! definition.method.scope "parent"))
|
||||
|
||||
((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
|
||||
(variable_declarator
|
||||
(identifier) @definition.function)
|
||||
(function_definition) @scope)
|
||||
(function_definition) @scope
|
||||
]
|
||||
(variable_declarator (identifier) @definition.function) . (function_definition))
|
||||
|
||||
;; Scopes
|
||||
[
|
||||
(program)
|
||||
(function)
|
||||
(local_function)
|
||||
(function_definition)
|
||||
(if_statement)
|
||||
(for_in_statement)
|
||||
(repeat_statement)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue