aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/tera/highlights.scm
blob: f41ad826f10a1c1f66293dbf913e543387be19a1 (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
; Variables
;----------
(identifier) @variable

((identifier) @variable.builtin
  (#any-of? @variable.builtin "loop" "__tera_context"))

; Properties
;-----------
(member_expression
  property: (identifier)? @variable.member)

; Literals
;-----------
(string) @string

(bool) @boolean

(number) @number

; Tokens
;-----------
[
  "."
  ","
  "::"
  (frontmatter_delimiter)
] @punctuation.delimiter

[
  "*"
  "/"
  "%"
  "|"
  "+"
  "-"
  "~"
  "="
  "=="
  "!="
  "<"
  ">"
  "<="
  ">="
] @operator

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

; Tags
;-----------
(comment_tag) @comment @spell

; Keywords
;-----------
[
  "if"
  "elif"
  "else"
  "endif"
] @keyword.conditional

[
  "for"
  "endfor"
] @keyword.repeat

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

[
  "in"
  "and"
  "or"
  "not"
  "is"
] @keyword.operator

[
  "break"
  "continue"
] @keyword.return

[
  "set"
  "set_global"
  "filter"
  "endfilter"
  "block"
  "endblock"
  "macro"
  "endmacro"
  "raw"
  "endraw"
  "as"
] @keyword

; Functions
;-----------
(macro_statement
  name: (identifier) @function
  (parameter_list
    parameter: (identifier) @variable.parameter
    (optional_parameter
      name: (identifier) @variable.parameter)))

(call_expression
  scope: (identifier)? @module
  name: (identifier) @function.call)

(call_expression
  scope: (identifier) @module.builtin
  name: (identifier) @function.call
  (#eq? @module.builtin "self"))

(call_expression
  name: (identifier) @function.builtin
  (#any-of? @function.builtin
    ; Functions - https://keats.github.io/tera/docs/#built-in-functions
    "range" "now" "throw" "get_random" "get_env"))

(test_expression
  test: (identifier) @function.call)

(test_expression
  test: (identifier) @function.builtin
  (#any-of? @function.builtin
    ; Tests - https://keats.github.io/tera/docs/#built-in-tests
    "defined" "undefined" "odd" "even" "string" "number" "divisibleby" "iterable" "object"
    "starting_with" "ending_with" "containing" "matching"))

(filter_expression
  filter: (identifier) @function.method.call)

; Namespaces
;-----------
(import_statement
  scope: (identifier) @module)