diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-05-15 18:49:21 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2020-05-16 19:32:02 +0200 |
| commit | a5c50262d905037ca69c80debb46aba3cc381201 (patch) | |
| tree | 5a67f08c348ee1b4c32a9eb24cb746fe790ba4bb /queries/python/locals.scm | |
| parent | Merge pull request #53 from vigoux/c-queries (diff) | |
| download | nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.tar nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.tar.gz nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.tar.bz2 nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.tar.lz nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.tar.xz nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.tar.zst nvim-treesitter-a5c50262d905037ca69c80debb46aba3cc381201.zip | |
Add python locals.scm
Diffstat (limited to 'queries/python/locals.scm')
| -rw-r--r-- | queries/python/locals.scm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/queries/python/locals.scm b/queries/python/locals.scm new file mode 100644 index 000000000..763d1b77d --- /dev/null +++ b/queries/python/locals.scm @@ -0,0 +1,65 @@ +;;; Programm structure +(module) @scope + +(class_definition + body: (block + (expression_statement + (assignment + left: (expression_list + (identifier) @definition.associated))))) @scope + +; Function with parameters, defines parameters +(function_definition + name: (identifier) + parameters: (parameters + (identifier) @definition.var)) + +; Function defines function and scope +(function_definition + name: (identifier) @definition.function) @scope + +(class_definition + name: (identifier) @definition.type) @scope + +(class_definition + body: (block + (function_definition + name: (identifier) @definition.method))) + +;;; Loops +; not a scope! +(for_statement + left: (variables + (identifier) @definition.var)) + +; not a scope! +;(while_statement) @scope + +; for in list comprehension +(for_in_clause + left: (variables + (identifier) @definition.var)) + +(dictionary_comprehension) @scope +(list_comprehension) @scope +(set_comprehension) @scope + +;;; Assignments + +(assignment + left: (expression_list + (identifier) @definition.var)) + +(assignment + left: (expression_list + (attribute + (identifier) + (identifier) @definition.field))) + +; Walrus operator x := 1 +(named_expression + (identifier) @definition.var) + + +;;; REFERENCES +(identifier) @reference |
