nvim-treesitter/queries/lua/locals.scm
Thomas Vigouroux b706c4e8ed feat: first version of locals
Locals will be the main interface to treesitter, through some functions:
    get_definitions(bufnr) : returns all the definitions in bufnr
    get_scopes(bufnr): returns all definitions in bufnr
    get_references(bufnr): returns all references in bufnr
2020-04-19 17:28:52 +02:00

45 lines
1.1 KiB
Scheme

;;; DECLARATIONS AND SCOPES
;; Variable and field declarations
((variable_declarator
(identifier) @definition)
(set! definition.kind "v"))
((variable_declarator
(field_expression object:(*) @definition.associated (property_identifier) @definition))
(set! difinition.kind "v"))
;; Parameters
((local_function
(parameters (identifier) @definition))
(set! definition.kind "v"))
((function
(parameters (identifier) @definition))
(set! definition.kind "v"))
;; Function definitions
;; Functions definitions creates both a definition and a new scope
((function
(function_name_field
object: (identifier) @definition.associated
(property_identifier) @definition)) @scope
(set! definition.kind "m"))
((function
(function_name (identifier) @definition)) @scope
(set! definition.kind "f"))
((local_function
(identifier) @definition) @scope
(set! definition.kind "f"))
((if_statement) @scope)
((for_in_statement) @scope)
((repeat_statement) @scope)
;; Loops
((loop_expression
(identifier) @definition)
(set! definition.kind "v"))
;;; REFERENCES
((identifier) @reference)