diff options
| author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-04-18 19:21:01 +0200 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2020-04-18 19:21:01 +0200 |
| commit | 00f871ab51e6d094c0cd83dc4668dbe7ec047d04 (patch) | |
| tree | fae1ea0323016b9e87a222b0a8edc84a8bcbbc3f /queries/lua | |
| parent | feat: add some utils to read queries (diff) | |
| download | nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.tar nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.tar.gz nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.tar.bz2 nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.tar.lz nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.tar.xz nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.tar.zst nvim-treesitter-00f871ab51e6d094c0cd83dc4668dbe7ec047d04.zip | |
feat: add an example locals query
This will be the guide for the implementation of locals extraction,
which is treesitters name of definition/scope.
Diffstat (limited to 'queries/lua')
| -rw-r--r-- | queries/lua/locals.scm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/queries/lua/locals.scm b/queries/lua/locals.scm new file mode 100644 index 000000000..a7b15d1e5 --- /dev/null +++ b/queries/lua/locals.scm @@ -0,0 +1,45 @@ +;;; DECLARATIONS AND SCOPES + +;; Variable and field declarations +((variable_declarator + (identifier) @definition) + (set! kind "v")) + +((variable_declarator + (field_expression object:(*) @definition.associated (property_identifier) @definition)) + (set! kind "v")) + +;; Parameters +((local_function + (parameters (identifier) @definition)) + (set! kind "v")) +((function + (parameters (identifier) @definition)) + (set! 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! kind "m")) + +((function + (function_name (identifier) @definition)) @scope + (set! kind "f")) + +((local_function + (identifier) @definition) @scope + (set! kind "f")) + +((if_statement) @scope) +((for_in_statement) @scope) +((repeat_statement) @scope) +;; Loops +((loop_expression + (identifier) @definition) + (set! kind "v")) + +;;; REFERENCES +((identifier) @reference) |
