aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/jq/highlights.scm
blob: 5d6050f4ce7c0a3c1b63e58e5817b6c804a154f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
; Variables
(variable) @variable

((variable) @constant.builtin
  (#eq? @constant.builtin "$ENV"))

((variable) @constant.macro
  (#eq? @constant.macro "$__loc__"))

; Properties
(index
  (identifier) @property)

; Labels
(query
  label: (variable) @label)

(query
  break_statement: (variable) @label)

; Literals
(number) @number

(string) @string

[
  "true"
  "false"
] @boolean

"null" @type.builtin

; Interpolation
[
  "\\("
  ")"
] @character.special

; Format
(format) @attribute

; Functions
(funcdef
  (identifier) @function)

(funcdefargs
  (identifier) @variable.parameter)

[
  "reduce"
  "foreach"
] @function.builtin

((funcname) @function.call
  .
  "(")

; jq -n 'builtins | map(split("/")[0]) | unique | .[]'
((funcname) @function.builtin
  (#any-of? @function.builtin
    "IN" "INDEX" "JOIN" "abs" "acos" "acosh" "add" "all" "any" "arrays" "ascii_downcase"
    "ascii_upcase" "asin" "asinh" "atan" "atan2" "atanh" "booleans" "bsearch" "builtins" "capture"
    "cbrt" "ceil" "combinations" "contains" "copysign" "cos" "cosh" "debug" "del" "delpaths" "drem"
    "empty" "endswith" "env" "erf" "erfc" "error" "exp" "exp10" "exp2" "explode" "expm1" "fabs"
    "fdim" "finites" "first" "flatten" "floor" "fma" "fmax" "fmin" "fmod" "format" "frexp"
    "from_entries" "fromdate" "fromdateiso8601" "fromjson" "fromstream" "gamma" "get_jq_origin"
    "get_prog_origin" "get_search_list" "getpath" "gmtime" "group_by" "gsub" "halt" "halt_error"
    "has" "hypot" "implode" "in" "index" "indices" "infinite" "input" "input_filename"
    "input_line_number" "inputs" "inside" "isempty" "isfinite" "isinfinite" "isnan" "isnormal"
    "iterables" "j0" "j1" "jn" "join" "keys" "keys_unsorted" "last" "ldexp" "length" "lgamma"
    "lgamma_r" "limit" "localtime" "log" "log10" "log1p" "log2" "logb" "ltrimstr" "map" "map_values"
    "match" "max" "max_by" "min" "min_by" "mktime" "modf" "modulemeta" "nan" "nearbyint" "nextafter"
    "nexttoward" "normals" "not" "now" "nth" "nulls" "numbers" "objects" "path" "paths" "pick" "pow"
    "pow10" "range" "recurse" "remainder" "repeat" "reverse" "rindex" "rint" "round" "rtrimstr"
    "scalars" "scalb" "scalbln" "scan" "select" "setpath" "significand" "sin" "sinh" "sort"
    "sort_by" "split" "splits" "sqrt" "startswith" "stderr" "strflocaltime" "strftime" "strings"
    "strptime" "sub" "tan" "tanh" "test" "tgamma" "to_entries" "todate" "todateiso8601" "tojson"
    "tonumber" "tostream" "tostring" "transpose" "trunc" "truncate_stream" "type" "unique"
    "unique_by" "until" "utf8bytelength" "values" "walk" "while" "with_entries" "y0" "y1" "yn"))

; Keywords
[
  "def"
  "as"
  "label"
  "module"
  "break"
] @keyword

[
  "import"
  "include"
] @keyword.import

[
  "if"
  "then"
  "elif"
  "else"
  "end"
] @keyword.conditional

[
  "try"
  "catch"
] @keyword.exception

[
  "or"
  "and"
] @keyword.operator

; Operators
[
  "."
  "=="
  "!="
  ">"
  ">="
  "<="
  "<"
  "="
  "+"
  "-"
  "*"
  "/"
  "%"
  "+="
  "-="
  "*="
  "/="
  "%="
  "//="
  "|"
  "?"
  "//"
  "?//"
  (recurse) ; ".."
] @operator

; Punctuation
[
  ";"
  ","
  ":"
] @punctuation.delimiter

[
  "["
  "]"
  "{"
  "}"
  "("
  ")"
] @punctuation.bracket

; Comments
(comment) @comment @spell