summaryrefslogtreecommitdiff
path: root/queries/latex/highlights.scm
blob: b9ded3d6b22d807b7a616b7d00e883957d938131 (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
;; General syntax
(ERROR) @error

(command_name) @function
(caption
  command: _ @function)

(key_value_pair
  key: (_) @parameter
  value: (_))

[
 (line_comment)
 (block_comment)
 (comment_environment)
] @comment

((line_comment) @preproc
  (#lua-match? @preproc "^%% !TeX"))

[
 (brack_group)
 (brack_group_argc)
] @parameter

[(operator) "="] @operator

"\\item" @punctuation.special

((word) @punctuation.delimiter
(#eq? @punctuation.delimiter "&"))

["[" "]" "{" "}"] @punctuation.bracket ; "(" ")" has no syntactical meaning in LaTeX

;; General environments
(begin
 command: _ @text.environment
 name: (curly_group_text (text) @text.environment.name))

(end
 command: _ @text.environment
 name: (curly_group_text (text) @text.environment.name))

;; Definitions and references
(new_command_definition
 command: _ @function.macro
 declaration: (curly_group_command_name (_) @function))
(old_command_definition
 command: _ @function.macro
 declaration: (_) @function)
(let_command_definition
 command: _ @function.macro
 declaration: (_) @function)

(environment_definition
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))

(theorem_definition
 command: _ @function.macro
 name: (curly_group_text (_) @text.environment.name))

(paired_delimiter_definition
 command: _ @function.macro
 declaration: (curly_group_command_name (_) @function))

(label_definition
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))
(label_reference_range
 command: _ @function.macro
 from: (curly_group_text (_) @text.reference)
 to: (curly_group_text (_) @text.reference))
(label_reference
 command: _ @function.macro
 names: (curly_group_text_list (_) @text.reference))
(label_number
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference)
 number: (_) @text.reference)

(citation
 command: _ @function.macro
 keys: (curly_group_text_list) @text.reference)

(glossary_entry_definition
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))
(glossary_entry_reference
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))

(acronym_definition
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))
(acronym_reference
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))

(color_definition
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))
(color_reference
 command: _ @function.macro
 name: (curly_group_text (_) @text.reference))

;; Math
[
 (displayed_equation)
 (inline_formula)
] @text.math

(math_environment
  (begin
   command: _ @text.math
   name: (curly_group_text (text) @text.math)))

(math_environment
  (text) @text.math)

(math_environment
  (end
   command: _ @text.math
   name: (curly_group_text (text) @text.math)))

;; Sectioning
(title_declaration
  command: _ @namespace
  options: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(author_declaration
  command: _ @namespace
  authors: (curly_group_author_list
             ((author)+ @text.title)))

(chapter
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(part
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(section
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(subsection
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(subsubsection
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(paragraph
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

(subparagraph
  command: _ @namespace
  toc: (brack_group (_) @text.title)?
  text: (curly_group (_) @text.title))

;; Beamer frames
(generic_environment
  (begin
    name: (curly_group_text
            (text) @text.environment.name)
    (#any-of? @text.environment.name "frame"))
  .
  (curly_group (_) @text.title))

((generic_command
  command: (command_name) @_name
  arg: (curly_group
          (text) @text.title))
 (#eq? @_name "\\frametitle"))

;; Formatting
((generic_command
  command: (command_name) @_name
  arg: (curly_group (_) @text.emphasis))
  (#eq? @_name "\\emph"))

((generic_command
  command: (command_name) @_name
  arg: (curly_group (_) @text.emphasis))
  (#match? @_name "^(\\\\textit|\\\\mathit)$"))

((generic_command
  command: (command_name) @_name
  arg: (curly_group (_) @text.strong))
  (#match? @_name "^(\\\\textbf|\\\\mathbf)$"))

((generic_command
  command: (command_name) @_name
  .
  arg: (curly_group (_) @text.uri))
 (#match? @_name "^(\\\\url|\\\\href)$"))

;; File inclusion commands
(class_include
  command: _ @include
  path: (curly_group_path) @string)

(package_include
  command: _ @include
  paths: (curly_group_path_list) @string)

(latex_include
  command: _ @include
  path: (curly_group_path) @string)
(import_include
  command: _ @include
  directory: (curly_group_path) @string
  file: (curly_group_path) @string)

(bibtex_include
  command: _ @include
  path: (curly_group_path) @string)
(biblatex_include
  "\\addbibresource" @include
  glob: (curly_group_glob_pattern) @string.regex)

(graphics_include
  command: _ @include
  path: (curly_group_path) @string)
(tikz_library_import
  command: _ @include
  paths: (curly_group_path_list) @string)

(
    (text) @spell
    (#not-has-parent? @spell
        inline_formula
        displayed_equation
    )
)