1
0

Add initial highlights.scm for syntax highlighting

This commit is contained in:
Jip J. Dekker 2021-01-15 15:43:42 +11:00
parent 6dd0013ce1
commit 2088b17243
2 changed files with 125 additions and 1 deletions

View File

@ -27,5 +27,15 @@
"devDependencies": {
"prettier": "2.2.1",
"tree-sitter-cli": "^0.16.9"
}
},
"tree-sitter": [
{
"scope": "source.minizinc",
"file-types": [
"mzn",
"fzn",
"dzn"
]
}
]
}

114
queries/highlights.scm Normal file
View File

@ -0,0 +1,114 @@
; Function calls
(call name: (identifier) @function)
; Function definitions
(function_item name: (identifier) @function)
(predicate name: (identifier) @function)
; Types
(primitive_type) @type.builtin
[
"array"
"of"
"par"
"set"
"var"
] @type.builtin
; Identifiers
(identifier) @variable
; Keywords
[
"annotation"
"constraint"
"else"
"elseif"
"endif"
"function"
"if"
"in"
"include"
"let"
"maximize"
"minimize"
"output"
"predicate"
"satisfy"
"solve"
"test"
"then"
"where"
] @keyword
; Operators
[
"<->"
"->"
"<-"
"\/"
"xor"
"/\"
"="
"=="
"!="
"<"
"<="
">"
">="
"in"
"subset"
"superset"
"union"
"diff"
"symdiff"
"intersect"
".."
"+"
"-"
"++"
"*"
"/"
"div"
"mod"
"^"
"::"
] @operator
; Punctuation
[
","
":"
";"
"|"
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
; Literals
[
(integer_literal)
(float_literal)
] @number
[
(string_literal)
(string_interpolation)
] @string
(escape_sequence) @escape
[
(absent)
(boolean_literal)
] @constant.builtin
; Comments
[
(block_comment)
(line_comment)
] @comment