aboutsummaryrefslogtreecommitdiffstats
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorSteven Sojka <steelsojka@users.noreply.github.com>2020-08-16 11:26:44 -0500
committerGitHub <noreply@github.com>2020-08-16 11:26:44 -0500
commit5462027bebe29a9ee7d1aa2f2f678c81d3be1283 (patch)
tree263e3880f84d7f2ea8d541207f8493f889258181 /CONTRIBUTING.md
parent[java] Add label highlight (diff)
parentfeat(definitions): allow setting of scope (diff)
downloadnvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.tar
nvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.tar.gz
nvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.tar.bz2
nvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.tar.lz
nvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.tar.xz
nvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.tar.zst
nvim-treesitter-5462027bebe29a9ee7d1aa2f2f678c81d3be1283.zip
Merge pull request #295 from steelsojka/feature/set-scopes-for-definitions
feat(defintions): allow setting of scope
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 62a38b71c..0e72dcb66 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -177,3 +177,30 @@ Mainly for markup languages.
@scope
@reference
```
+
+#### Definition Scope
+
+You can set the scope of a definition by setting the `scope` property on the definition.
+
+For example, a javascript function declaration creates a scope. The function name is captured as the definition.
+This means that the function definition would only be available WITHIN the scope of the function, which is not the case.
+The definition can be used in the scope the function was defined in.
+
+```javascript
+function doSomething() {}
+
+doSomething(); // Should point to the declaration as the definition
+```
+
+```scheme
+(function_declaration
+ ((identifier) @definition.var)
+ (set! "definition.var.scope" "parent"))
+```
+
+Possible scope values are:
+
+- `parent`: The definition is valid in the containing scope and one more scope above that scope
+- `global`: The definition is valid in the root scope
+- `local`: The definition is valid in the containing scope. This is the default behavior
+