mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -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)
|
||||
(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
|
||||
|
|
|
|||
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