aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/jsonnet
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/queries/jsonnet')
-rw-r--r--runtime/queries/jsonnet/folds.scm10
-rw-r--r--runtime/queries/jsonnet/highlights.scm135
-rw-r--r--runtime/queries/jsonnet/injections.scm2
-rw-r--r--runtime/queries/jsonnet/locals.scm27
4 files changed, 174 insertions, 0 deletions
diff --git a/runtime/queries/jsonnet/folds.scm b/runtime/queries/jsonnet/folds.scm
new file mode 100644
index 000000000..91257a790
--- /dev/null
+++ b/runtime/queries/jsonnet/folds.scm
@@ -0,0 +1,10 @@
+[
+ (field)
+ (object)
+ (array)
+ (parenthesis)
+ (bind)
+ ; (params)
+ ; (args)
+ ; (conditional)
+] @fold
diff --git a/runtime/queries/jsonnet/highlights.scm b/runtime/queries/jsonnet/highlights.scm
new file mode 100644
index 000000000..1e67baa32
--- /dev/null
+++ b/runtime/queries/jsonnet/highlights.scm
@@ -0,0 +1,135 @@
+(id) @variable
+
+(comment) @comment @spell
+
+; Literals
+(null) @constant.builtin
+
+(string) @string
+
+(number) @number
+
+[
+ (true)
+ (false)
+] @boolean
+
+; Keywords
+"for" @keyword.repeat
+
+"in" @keyword.operator
+
+"function" @keyword.function
+
+[
+ "if"
+ "then"
+ "else"
+] @keyword.conditional
+
+[
+ (local)
+ (tailstrict)
+ "function"
+] @keyword
+
+[
+ "assert"
+ "error"
+] @keyword.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
+[
+ "["
+ "]"
+ "{"
+ "}"
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+ ";"
+ ":"
+] @punctuation.delimiter
+
+[
+ "::"
+ ":::"
+] @punctuation.special
+
+(field
+ (fieldname)
+ "+" @punctuation.special)
+
+; Imports
+[
+ (import)
+ (importstr)
+] @keyword.import
+
+; Fields
+(fieldname
+ (id) @variable.member)
+
+(fieldname
+ (string
+ (string_content) @variable.member))
+
+; Functions
+(field
+ function: (fieldname
+ (id) @function))
+
+(field
+ function: (fieldname
+ (string
+ (string_content) @function)))
+
+(param
+ identifier: (id) @variable.parameter)
+
+(bind
+ (id) @variable)
+
+(bind
+ function: (id) @function)
+
+; Function call
+(functioncall
+ (fieldaccess
+ last: (id) @function.call)?
+ (fieldaccess_super
+ (id) @function.call)?
+ (id)? @function.call
+ "("
+ (args
+ (named_argument
+ (id) @variable.parameter))?
+ ")")
diff --git a/runtime/queries/jsonnet/injections.scm b/runtime/queries/jsonnet/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/runtime/queries/jsonnet/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/jsonnet/locals.scm b/runtime/queries/jsonnet/locals.scm
new file mode 100644
index 000000000..778077764
--- /dev/null
+++ b/runtime/queries/jsonnet/locals.scm
@@ -0,0 +1,27 @@
+(parenthesis) @local.scope
+
+(anonymous_function) @local.scope
+
+(object) @local.scope
+
+(field) @local.scope
+
+(local_bind) @local.scope
+
+(field
+ function: (fieldname
+ (id) @local.definition.function)
+ (#set! definition.function.scope "parent"))
+
+(bind
+ (id) @local.definition.var)
+
+(bind
+ function: (id) @local.definition.function)
+
+(param
+ (id) @local.definition.parameter)
+
+(id) @local.reference
+
+;(fieldname (id) (#is-not? local)) ; (#is-not?) not supported yet