Regenerate nvim config
This commit is contained in:
124
config/neovim/store/nvim-treesitter/queries/python/locals.scm
Normal file
124
config/neovim/store/nvim-treesitter/queries/python/locals.scm
Normal file
@ -0,0 +1,124 @@
|
||||
; Program structure
|
||||
(module) @local.scope
|
||||
|
||||
(class_definition
|
||||
body: (block
|
||||
(expression_statement
|
||||
(assignment
|
||||
left: (identifier) @local.definition.field)))) @local.scope
|
||||
|
||||
(class_definition
|
||||
body: (block
|
||||
(expression_statement
|
||||
(assignment
|
||||
left: (_
|
||||
(identifier) @local.definition.field))))) @local.scope
|
||||
|
||||
; Imports
|
||||
(aliased_import
|
||||
alias: (identifier) @local.definition.import)
|
||||
|
||||
(import_statement
|
||||
name: (dotted_name
|
||||
(identifier) @local.definition.import))
|
||||
|
||||
(import_from_statement
|
||||
name: (dotted_name
|
||||
(identifier) @local.definition.import))
|
||||
|
||||
; Function with parameters, defines parameters
|
||||
(parameters
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
(default_parameter
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
(typed_parameter
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
(typed_default_parameter
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
; *args parameter
|
||||
(parameters
|
||||
(list_splat_pattern
|
||||
(identifier) @local.definition.parameter))
|
||||
|
||||
; **kwargs parameter
|
||||
(parameters
|
||||
(dictionary_splat_pattern
|
||||
(identifier) @local.definition.parameter))
|
||||
|
||||
; Function defines function and scope
|
||||
((function_definition
|
||||
name: (identifier) @local.definition.function) @local.scope
|
||||
(#set! definition.function.scope "parent"))
|
||||
|
||||
((class_definition
|
||||
name: (identifier) @local.definition.type) @local.scope
|
||||
(#set! definition.type.scope "parent"))
|
||||
|
||||
(class_definition
|
||||
body: (block
|
||||
(function_definition
|
||||
name: (identifier) @local.definition.method)))
|
||||
|
||||
; Loops
|
||||
; not a scope!
|
||||
(for_statement
|
||||
left: (pattern_list
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(for_statement
|
||||
left: (tuple_pattern
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(for_statement
|
||||
left: (identifier) @local.definition.var)
|
||||
|
||||
; not a scope!
|
||||
;(while_statement) @local.scope
|
||||
; for in list comprehension
|
||||
(for_in_clause
|
||||
left: (identifier) @local.definition.var)
|
||||
|
||||
(for_in_clause
|
||||
left: (tuple_pattern
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(for_in_clause
|
||||
left: (pattern_list
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(dictionary_comprehension) @local.scope
|
||||
|
||||
(list_comprehension) @local.scope
|
||||
|
||||
(set_comprehension) @local.scope
|
||||
|
||||
; Assignments
|
||||
(assignment
|
||||
left: (identifier) @local.definition.var)
|
||||
|
||||
(assignment
|
||||
left: (pattern_list
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(assignment
|
||||
left: (tuple_pattern
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(assignment
|
||||
left: (attribute
|
||||
(identifier)
|
||||
(identifier) @local.definition.field))
|
||||
|
||||
; Walrus operator x := 1
|
||||
(named_expression
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(as_pattern
|
||||
alias: (as_pattern_target) @local.definition.var)
|
||||
|
||||
; REFERENCES
|
||||
(identifier) @local.reference
|
||||
Reference in New Issue
Block a user