diff options
| author | Jeroen Op 't Eynde <jeroen@simplistic.be> | 2023-08-25 19:55:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-25 13:55:22 -0400 |
| commit | 4d41d9bfb09dd0836ce6910404e3cd570500c9ca (patch) | |
| tree | dd7ce2e4bf36210376be5df780bcfbe77d96e49d | |
| parent | Update parsers: bash, javascript, rust, wing (diff) | |
| download | nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.tar nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.tar.gz nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.tar.bz2 nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.tar.lz nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.tar.xz nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.tar.zst nvim-treesitter-4d41d9bfb09dd0836ce6910404e3cd570500c9ca.zip | |
feat(jsonnet): update parser and queries
| -rw-r--r-- | queries/jsonnet/folds.scm | 10 | ||||
| -rw-r--r-- | queries/jsonnet/highlights.scm | 137 | ||||
| -rw-r--r-- | queries/jsonnet/locals.scm | 17 |
3 files changed, 110 insertions, 54 deletions
diff --git a/queries/jsonnet/folds.scm b/queries/jsonnet/folds.scm new file mode 100644 index 000000000..9243ccfde --- /dev/null +++ b/queries/jsonnet/folds.scm @@ -0,0 +1,10 @@ +[ + (field) + (object) + (array) + (parenthesis) + (bind) +; (params) +; (args) +; (conditional) +] @fold diff --git a/queries/jsonnet/highlights.scm b/queries/jsonnet/highlights.scm index 189f4b9e1..b0769c639 100644 --- a/queries/jsonnet/highlights.scm +++ b/queries/jsonnet/highlights.scm @@ -1,21 +1,61 @@ +(id) @variable +(comment) @comment + +; Literals +(null) @constant.builtin +(string) @string +(number) @number [ (true) (false) ] @boolean -(comment) @comment -(id) @variable -(import) @include -(null) @constant.builtin -(number) @number -(string) @string +; Keywords +"for" @repeat +"in" @keyword.operator +"function" @keyword.function -(fieldname (id) @field) -(fieldaccess - last: (id) @field) -(fieldaccess_super - (id) @field) +[ + "if" + "then" + "else" +] @conditional + +[ + (local) + (tailstrict) + "function" +] @keyword + +[ + "assert" + "error" +] @exception + +[ + (dollar) + (self) + (super) +] @variable.builtin +((id) @variable.builtin + (#eq? @variable.builtin "std")) + +; Operators +[ + (multiplicative) + (additive) + (bitshift) + (comparison) + (equality) + (bitand) + (bitxor) + (bitor) + (and) + (or) + (unaryop) +] @operator +; Punctuation [ "[" "]" @@ -30,63 +70,52 @@ "," ";" ":" - "::" - ":::" ] @punctuation.delimiter -; Nested field inheritance -("+" @punctuation.delimiter [":" "::" ":::"]) - -"=" @operator -(unaryop) @operator -(binary - operator: (_) @operator) - -"for" @repeat - -"function" @keyword.function - -"in" @keyword.operator - [ - (local) - (tailstrict) - "assert" -] @keyword + "::" + ":::" +] @punctuation.special + +(field + (fieldname) "+" @punctuation.special) +; Imports [ - "else" - "if" - "then" -] @conditional + (import) + (importstr) +] @include -"error" @exception +; Fields -[ - (dollar) - (self) - (super) -] @variable.builtin -((id) @variable.builtin - (#eq? @variable.builtin "std")) +(fieldname (id) @field) +(fieldname (string (string_content) @field)) -; Function declaration +; Functions +(field + function: (fieldname (id) @function)) +(field + function: (fieldname + (string (string_content) @function))) (param identifier: (id) @parameter) -(field - (fieldname (id) @function) - [(anonymous_function) (params)]) -(bind - function: (id) @function) + +(bind (id) @variable.local) +(bind function: (id) @function) ; Function call -(functioncall (id) @function.call) (functioncall (fieldaccess - last: (id) @function.call)) -(functioncall + last: (id) @function.call)? (fieldaccess_super - (id) @function.call)) -(named_argument (id) @parameter) + (id) @function.call)? + (id)? @function.call + "(" + (args + (named_argument + (id) @parameter + ))? + ")") +; ERROR (ERROR) @error diff --git a/queries/jsonnet/locals.scm b/queries/jsonnet/locals.scm new file mode 100644 index 000000000..5e1f1acc2 --- /dev/null +++ b/queries/jsonnet/locals.scm @@ -0,0 +1,17 @@ +(parenthesis) @scope +(anonymous_function) @scope +(object) @scope +(field) @scope +(local_bind) @scope + +(field + function: (fieldname (id) @definition.function) + (#set! "definition.function.scope" "parent")) + +(bind (id) @definition.var) +(bind function: (id) @definition.function) + +(param (id) @definition.parameter) + +(id) @reference +;(fieldname (id) (#is-not? local)) ; (#is-not?) not supported yet |
