mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 02:10:15 -04:00
feat(jsonnet): update parser and queries
This commit is contained in:
parent
bae2c1824f
commit
4d41d9bfb0
3 changed files with 110 additions and 54 deletions
10
queries/jsonnet/folds.scm
Normal file
10
queries/jsonnet/folds.scm
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[
|
||||||
|
(field)
|
||||||
|
(object)
|
||||||
|
(array)
|
||||||
|
(parenthesis)
|
||||||
|
(bind)
|
||||||
|
; (params)
|
||||||
|
; (args)
|
||||||
|
; (conditional)
|
||||||
|
] @fold
|
||||||
|
|
@ -1,21 +1,61 @@
|
||||||
|
(id) @variable
|
||||||
|
(comment) @comment
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
(null) @constant.builtin
|
||||||
|
(string) @string
|
||||||
|
(number) @number
|
||||||
[
|
[
|
||||||
(true)
|
(true)
|
||||||
(false)
|
(false)
|
||||||
] @boolean
|
] @boolean
|
||||||
|
|
||||||
(comment) @comment
|
; Keywords
|
||||||
(id) @variable
|
"for" @repeat
|
||||||
(import) @include
|
"in" @keyword.operator
|
||||||
(null) @constant.builtin
|
"function" @keyword.function
|
||||||
(number) @number
|
|
||||||
(string) @string
|
|
||||||
|
|
||||||
(fieldname (id) @field)
|
[
|
||||||
(fieldaccess
|
"if"
|
||||||
last: (id) @field)
|
"then"
|
||||||
(fieldaccess_super
|
"else"
|
||||||
(id) @field)
|
] @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
|
] @punctuation.delimiter
|
||||||
|
|
||||||
; Nested field inheritance
|
|
||||||
("+" @punctuation.delimiter [":" "::" ":::"])
|
|
||||||
|
|
||||||
"=" @operator
|
|
||||||
(unaryop) @operator
|
|
||||||
(binary
|
|
||||||
operator: (_) @operator)
|
|
||||||
|
|
||||||
"for" @repeat
|
|
||||||
|
|
||||||
"function" @keyword.function
|
|
||||||
|
|
||||||
"in" @keyword.operator
|
|
||||||
|
|
||||||
[
|
[
|
||||||
(local)
|
"::"
|
||||||
(tailstrict)
|
":::"
|
||||||
"assert"
|
] @punctuation.special
|
||||||
] @keyword
|
|
||||||
|
|
||||||
|
(field
|
||||||
|
(fieldname) "+" @punctuation.special)
|
||||||
|
|
||||||
|
; Imports
|
||||||
[
|
[
|
||||||
"else"
|
(import)
|
||||||
"if"
|
(importstr)
|
||||||
"then"
|
] @include
|
||||||
] @conditional
|
|
||||||
|
|
||||||
"error" @exception
|
; Fields
|
||||||
|
|
||||||
[
|
(fieldname (id) @field)
|
||||||
(dollar)
|
(fieldname (string (string_content) @field))
|
||||||
(self)
|
|
||||||
(super)
|
|
||||||
] @variable.builtin
|
|
||||||
((id) @variable.builtin
|
|
||||||
(#eq? @variable.builtin "std"))
|
|
||||||
|
|
||||||
; Function declaration
|
; Functions
|
||||||
|
(field
|
||||||
|
function: (fieldname (id) @function))
|
||||||
|
(field
|
||||||
|
function: (fieldname
|
||||||
|
(string (string_content) @function)))
|
||||||
(param
|
(param
|
||||||
identifier: (id) @parameter)
|
identifier: (id) @parameter)
|
||||||
(field
|
|
||||||
(fieldname (id) @function)
|
(bind (id) @variable.local)
|
||||||
[(anonymous_function) (params)])
|
(bind function: (id) @function)
|
||||||
(bind
|
|
||||||
function: (id) @function)
|
|
||||||
|
|
||||||
; Function call
|
; Function call
|
||||||
(functioncall (id) @function.call)
|
|
||||||
(functioncall
|
(functioncall
|
||||||
(fieldaccess
|
(fieldaccess
|
||||||
last: (id) @function.call))
|
last: (id) @function.call)?
|
||||||
(functioncall
|
|
||||||
(fieldaccess_super
|
(fieldaccess_super
|
||||||
(id) @function.call))
|
(id) @function.call)?
|
||||||
(named_argument (id) @parameter)
|
(id)? @function.call
|
||||||
|
"("
|
||||||
|
(args
|
||||||
|
(named_argument
|
||||||
|
(id) @parameter
|
||||||
|
))?
|
||||||
|
")")
|
||||||
|
|
||||||
|
; ERROR
|
||||||
(ERROR) @error
|
(ERROR) @error
|
||||||
|
|
|
||||||
17
queries/jsonnet/locals.scm
Normal file
17
queries/jsonnet/locals.scm
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue