mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
chore(latex)!: update parser and queries (#2436)
BREAKING CHANGE: queries for latex need adaptation
This commit is contained in:
parent
7867d997e7
commit
a80c8bc506
5 changed files with 201 additions and 210 deletions
|
|
@ -150,7 +150,7 @@
|
||||||
"revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569"
|
"revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569"
|
||||||
},
|
},
|
||||||
"latex": {
|
"latex": {
|
||||||
"revision": "6f796b700c69a8af28132e84ed6d0c8f0c17a5e2"
|
"revision": "f112e7ab87061a5338259d9773f917e55053b149"
|
||||||
},
|
},
|
||||||
"ledger": {
|
"ledger": {
|
||||||
"revision": "0cdeb0e51411a3ba5493662952c3039de08939ca"
|
"revision": "0cdeb0e51411a3ba5493662952c3039de08939ca"
|
||||||
|
|
|
||||||
|
|
@ -747,11 +747,11 @@ list.beancount = {
|
||||||
list.latex = {
|
list.latex = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/latex-lsp/tree-sitter-latex",
|
url = "https://github.com/latex-lsp/tree-sitter-latex",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
},
|
},
|
||||||
filetype = "tex",
|
filetype = "tex",
|
||||||
used_by = { "cls", "sty" },
|
used_by = { "cls", "sty" },
|
||||||
maintainers = { "@theHamsta by asking @clason" },
|
maintainers = { "@theHamsta, @clason" },
|
||||||
}
|
}
|
||||||
|
|
||||||
list.bibtex = {
|
list.bibtex = {
|
||||||
|
|
@ -760,7 +760,7 @@ list.bibtex = {
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
filetype = "bib",
|
filetype = "bib",
|
||||||
maintainers = { "@theHamsta by asking @clason" },
|
maintainers = { "@theHamsta, @clason" },
|
||||||
}
|
}
|
||||||
|
|
||||||
list.zig = {
|
list.zig = {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
(paragraph)
|
(paragraph)
|
||||||
(subparagraph)
|
(subparagraph)
|
||||||
|
|
||||||
(environment)
|
(generic_environment)
|
||||||
|
(comment_environment)
|
||||||
(displayed_equation)
|
(displayed_equation)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
(inline_formula)
|
(inline_formula)
|
||||||
] @text.math
|
] @text.math
|
||||||
|
|
||||||
;; This highlights the whole environment like vimtex does
|
((generic_environment
|
||||||
((environment
|
|
||||||
(begin
|
(begin
|
||||||
name: (word) @_env)) @text.math
|
name: (curly_group_text
|
||||||
|
(text) @_env))) @text.math
|
||||||
(#any-of? @_env
|
(#any-of? @_env
|
||||||
"displaymath" "displaymath*"
|
"displaymath" "displaymath*"
|
||||||
"equation" "equation*"
|
"equation" "equation*"
|
||||||
|
|
@ -20,8 +20,27 @@
|
||||||
"gather" "gather*"
|
"gather" "gather*"
|
||||||
"flalign" "flalign*"))
|
"flalign" "flalign*"))
|
||||||
|
|
||||||
|
;; File inclusion commands
|
||||||
[
|
[
|
||||||
(generic_command_name)
|
"\\documentclass"
|
||||||
|
"\\usepackage"
|
||||||
|
"\\input"
|
||||||
|
"\\include"
|
||||||
|
"\\subfile"
|
||||||
|
"\\subfileinclude"
|
||||||
|
"\\subfileinclude"
|
||||||
|
"\\includegraphics"
|
||||||
|
"\\addbibresource"
|
||||||
|
"\\bibliography"
|
||||||
|
"\\includesvg"
|
||||||
|
"\\includeinkscape"
|
||||||
|
"\\usepgflibrary"
|
||||||
|
"\\usetikzlibrary"
|
||||||
|
] @include
|
||||||
|
|
||||||
|
;; Definitions
|
||||||
|
[
|
||||||
|
(command_name)
|
||||||
"\\newcommand"
|
"\\newcommand"
|
||||||
"\\renewcommand"
|
"\\renewcommand"
|
||||||
"\\DeclareRobustCommand"
|
"\\DeclareRobustCommand"
|
||||||
|
|
@ -41,127 +60,97 @@
|
||||||
"\\newacronym"
|
"\\newacronym"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
|
|
||||||
|
;; References (labels)
|
||||||
[
|
[
|
||||||
"\\ref"
|
"\\ref"
|
||||||
"\\eqref"
|
"\\eqref"
|
||||||
"\\vref"
|
"\\vref"
|
||||||
"\\Vref"
|
"\\Vref"
|
||||||
"\\autoref"
|
"\\autoref"
|
||||||
"\\pageref"
|
"\\pageref"
|
||||||
"\\cref"
|
"\\cref"
|
||||||
"\\Cref"
|
"\\Cref"
|
||||||
"\\cref*"
|
"\\cref*"
|
||||||
"\\Cref*"
|
"\\Cref*"
|
||||||
"\\namecref"
|
"\\namecref"
|
||||||
"\\nameCref"
|
"\\nameCref"
|
||||||
"\\lcnamecref"
|
"\\lcnamecref"
|
||||||
"\\namecrefs"
|
"\\namecrefs"
|
||||||
"\\nameCrefs"
|
"\\nameCrefs"
|
||||||
"\\lcnamecrefs"
|
"\\lcnamecrefs"
|
||||||
"\\labelcref"
|
"\\labelcref"
|
||||||
"\\labelcpageref"
|
"\\labelcpageref"
|
||||||
"\\crefrange"
|
"\\crefrange"
|
||||||
"\\crefrange"
|
"\\crefrange"
|
||||||
"\\Crefrange"
|
"\\Crefrange"
|
||||||
"\\Crefrange"
|
"\\Crefrange"
|
||||||
"\\crefrange*"
|
"\\crefrange*"
|
||||||
"\\crefrange*"
|
"\\crefrange*"
|
||||||
"\\Crefrange*"
|
"\\Crefrange*"
|
||||||
"\\Crefrange*"
|
"\\Crefrange*"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
|
|
||||||
|
;; References (bibliography)
|
||||||
[
|
[
|
||||||
"\\cite"
|
"\\cite"
|
||||||
"\\cite*"
|
"\\cite*"
|
||||||
"\\Cite"
|
"\\Cite"
|
||||||
"\\nocite"
|
"\\nocite"
|
||||||
"\\citet"
|
"\\citet"
|
||||||
"\\citep"
|
"\\citep"
|
||||||
"\\citet*"
|
"\\citet*"
|
||||||
"\\citep*"
|
"\\citep*"
|
||||||
"\\citeauthor"
|
"\\citeauthor"
|
||||||
"\\citeauthor*"
|
"\\citeauthor*"
|
||||||
"\\Citeauthor"
|
"\\Citeauthor"
|
||||||
"\\Citeauthor*"
|
"\\Citeauthor*"
|
||||||
"\\citetitle"
|
"\\citetitle"
|
||||||
"\\citetitle*"
|
"\\citetitle*"
|
||||||
"\\citeyear"
|
"\\citeyear"
|
||||||
"\\citeyear*"
|
"\\citeyear*"
|
||||||
"\\citedate"
|
"\\citedate"
|
||||||
"\\citedate*"
|
"\\citedate*"
|
||||||
"\\citeurl"
|
"\\citeurl"
|
||||||
"\\fullcite"
|
"\\fullcite"
|
||||||
"\\citeyearpar"
|
"\\citeyearpar"
|
||||||
"\\citealt"
|
"\\citealt"
|
||||||
"\\citealp"
|
"\\citealp"
|
||||||
"\\citetext"
|
"\\citetext"
|
||||||
"\\parencite"
|
"\\parencite"
|
||||||
"\\parencite*"
|
"\\parencite*"
|
||||||
"\\Parencite"
|
"\\Parencite"
|
||||||
"\\footcite"
|
"\\footcite"
|
||||||
"\\footfullcite"
|
"\\footfullcite"
|
||||||
"\\footcitetext"
|
"\\footcitetext"
|
||||||
"\\textcite"
|
"\\textcite"
|
||||||
"\\Textcite"
|
"\\Textcite"
|
||||||
"\\smartcite"
|
"\\smartcite"
|
||||||
"\\Smartcite"
|
"\\Smartcite"
|
||||||
"\\supercite"
|
"\\supercite"
|
||||||
"\\autocite"
|
"\\autocite"
|
||||||
"\\Autocite"
|
"\\Autocite"
|
||||||
"\\autocite*"
|
"\\autocite*"
|
||||||
"\\Autocite*"
|
"\\Autocite*"
|
||||||
"\\volcite"
|
"\\volcite"
|
||||||
"\\Volcite"
|
"\\Volcite"
|
||||||
"\\pvolcite"
|
"\\pvolcite"
|
||||||
"\\Pvolcite"
|
"\\Pvolcite"
|
||||||
"\\fvolcite"
|
"\\fvolcite"
|
||||||
"\\ftvolcite"
|
"\\ftvolcite"
|
||||||
"\\svolcite"
|
"\\svolcite"
|
||||||
"\\Svolcite"
|
"\\Svolcite"
|
||||||
"\\tvolcite"
|
"\\tvolcite"
|
||||||
"\\Tvolcite"
|
"\\Tvolcite"
|
||||||
"\\avolcite"
|
"\\avolcite"
|
||||||
"\\Avolcite"
|
"\\Avolcite"
|
||||||
"\\notecite"
|
"\\notecite"
|
||||||
"\\notecite"
|
"\\notecite"
|
||||||
"\\pnotecite"
|
"\\pnotecite"
|
||||||
"\\Pnotecite"
|
"\\Pnotecite"
|
||||||
"\\fnotecite"
|
"\\fnotecite"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
|
|
||||||
[
|
;; References (glossary)
|
||||||
"\\ref"
|
|
||||||
"\\vref"
|
|
||||||
"\\Vref"
|
|
||||||
"\\autoref"
|
|
||||||
"\\pageref"
|
|
||||||
"\\cref"
|
|
||||||
"\\Cref"
|
|
||||||
"\\cref*"
|
|
||||||
"\\Cref*"
|
|
||||||
"\\namecref"
|
|
||||||
"\\nameCref"
|
|
||||||
"\\lcnamecref"
|
|
||||||
"\\namecrefs"
|
|
||||||
"\\nameCrefs"
|
|
||||||
"\\lcnamecrefs"
|
|
||||||
"\\labelcref"
|
|
||||||
"\\labelcpageref"
|
|
||||||
] @function.macro
|
|
||||||
|
|
||||||
|
|
||||||
[
|
|
||||||
"\\crefrange"
|
|
||||||
"\\crefrange"
|
|
||||||
"\\Crefrange"
|
|
||||||
"\\Crefrange"
|
|
||||||
"\\crefrange*"
|
|
||||||
"\\crefrange*"
|
|
||||||
"\\Crefrange*"
|
|
||||||
"\\Crefrange*"
|
|
||||||
] @function.macro
|
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"\\gls"
|
"\\gls"
|
||||||
"\\Gls"
|
"\\Gls"
|
||||||
|
|
@ -211,7 +200,7 @@
|
||||||
"\\GLSuservi"
|
"\\GLSuservi"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
|
|
||||||
|
;; Acronyms
|
||||||
[
|
[
|
||||||
"\\acrshort"
|
"\\acrshort"
|
||||||
"\\Acrshort"
|
"\\Acrshort"
|
||||||
|
|
@ -258,28 +247,45 @@
|
||||||
"\\Glsentryfullpl"
|
"\\Glsentryfullpl"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
|
|
||||||
(comment) @comment
|
;; General syntax
|
||||||
|
|
||||||
(bracket_group) @parameter
|
|
||||||
|
|
||||||
[(math_operator) "="] @operator
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"\\usepackage"
|
(line_comment)
|
||||||
"\\documentclass"
|
(block_comment)
|
||||||
"\\input"
|
(comment_environment)
|
||||||
"\\include"
|
] @comment
|
||||||
"\\subfile"
|
|
||||||
"\\subfileinclude"
|
(brack_group) @parameter
|
||||||
"\\subfileinclude"
|
|
||||||
"\\includegraphics"
|
[(operator) "="] @operator
|
||||||
"\\addbibresource"
|
|
||||||
"\\bibliography"
|
"\\item" @punctuation.special
|
||||||
"\\includesvg"
|
|
||||||
"\\includeinkscape"
|
((word) @punctuation.delimiter
|
||||||
"\\usepgflibrary"
|
(#eq? @punctuation.delimiter "&"))
|
||||||
"\\usetikzlibrary"
|
|
||||||
] @include
|
["$" "\\[" "\\]" "\\(" "\\)"] @punctuation.delimiter
|
||||||
|
|
||||||
|
(label_definition
|
||||||
|
name: (_) @text.reference)
|
||||||
|
(label_reference_range
|
||||||
|
from: (_) @text.reference
|
||||||
|
to: (_) @text.reference)
|
||||||
|
(label_reference
|
||||||
|
names: (_) @text.reference)
|
||||||
|
(label_number
|
||||||
|
name: (_) @text.reference
|
||||||
|
number: (_) @text.reference)
|
||||||
|
|
||||||
|
(citation
|
||||||
|
keys: (curly_group_text_list) @text.reference)
|
||||||
|
|
||||||
|
(key_value_pair
|
||||||
|
key: (_) @parameter
|
||||||
|
value: (_))
|
||||||
|
|
||||||
|
["[" "]" "{" "}"] @punctuation.bracket ; "(" ")" has no syntactical meaning in LaTeX
|
||||||
|
|
||||||
|
;; Sectioning
|
||||||
|
|
||||||
[
|
[
|
||||||
"\\part"
|
"\\part"
|
||||||
|
|
@ -305,101 +311,74 @@
|
||||||
"\\addpart*"
|
"\\addpart*"
|
||||||
"\\addchap*"
|
"\\addchap*"
|
||||||
"\\addsec*"
|
"\\addsec*"
|
||||||
] @type
|
] @namespace
|
||||||
|
|
||||||
"\\item" @punctuation.special
|
|
||||||
|
|
||||||
((word) @punctuation.delimiter
|
|
||||||
(#eq? @punctuation.delimiter "&"))
|
|
||||||
|
|
||||||
["$" "\\[" "\\]" "\\(" "\\)"] @punctuation.delimiter
|
|
||||||
|
|
||||||
(label_definition
|
|
||||||
name: (_) @text.reference)
|
|
||||||
(label_reference
|
|
||||||
label: (_) @text.reference)
|
|
||||||
(equation_label_reference
|
|
||||||
label: (_) @text.reference)
|
|
||||||
(label_reference
|
|
||||||
label: (_) @text.reference)
|
|
||||||
(label_number
|
|
||||||
label: (_) @text.reference)
|
|
||||||
|
|
||||||
(citation
|
|
||||||
key: (word) @text.reference)
|
|
||||||
|
|
||||||
(key_val_pair
|
|
||||||
key: (_) @parameter
|
|
||||||
value: (_))
|
|
||||||
|
|
||||||
["[" "]" "{" "}"] @punctuation.bracket ;"(" ")" is has no special meaning in LaTeX
|
|
||||||
|
|
||||||
(chapter
|
(chapter
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
(part
|
(part
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
(section
|
(section
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
(subsection
|
(subsection
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
(subsubsection
|
(subsubsection
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
(paragraph
|
(paragraph
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
(subparagraph
|
(subparagraph
|
||||||
text: (brace_group) @text.title)
|
text: (curly_group) @text.title)
|
||||||
|
|
||||||
((environment
|
(generic_environment
|
||||||
(begin
|
(begin
|
||||||
name: (word) @_frame)
|
name: (curly_group_text
|
||||||
(brace_group
|
(text) @text.environment.name)
|
||||||
child: (text) @text.title))
|
(#any-of? @text.environment.name "frame"))
|
||||||
(#eq? @_frame "frame"))
|
.
|
||||||
|
(curly_group (_) @text.title))
|
||||||
|
|
||||||
((generic_command
|
((command
|
||||||
name:(generic_command_name) @_name
|
command: (command_name) @_name
|
||||||
arg: (brace_group
|
arg: (curly_group
|
||||||
(text) @text.title))
|
(text) @text.title))
|
||||||
(#eq? @_name "\\frametitle"))
|
(#eq? @_name "\\frametitle"))
|
||||||
|
|
||||||
;; Formatting
|
;; Formatting
|
||||||
|
((command
|
||||||
|
command: (command_name) @_name
|
||||||
|
arg: (curly_group (_) @text.emphasis))
|
||||||
|
(#eq? @_name "\\emph"))
|
||||||
|
|
||||||
((generic_command
|
((command
|
||||||
name:(generic_command_name) @_name
|
command: (command_name) @_name
|
||||||
arg: (_) @text.emphasis)
|
arg: (curly_group (_) @text.emphasis))
|
||||||
(#eq? @_name "\\emph"))
|
(#match? @_name "^(\\\\textit|\\\\mathit)$"))
|
||||||
|
|
||||||
((generic_command
|
((command
|
||||||
name:(generic_command_name) @_name
|
command: (command_name) @_name
|
||||||
arg: (_) @text.emphasis)
|
arg: (curly_group (_) @text.strong))
|
||||||
(#match? @_name "^(\\\\textit|\\\\mathit)$"))
|
(#match? @_name "^(\\\\textbf|\\\\mathbf)$"))
|
||||||
|
|
||||||
((generic_command
|
((command
|
||||||
name:(generic_command_name) @_name
|
command: (command_name) @_name
|
||||||
arg: (_) @text.strong)
|
|
||||||
(#match? @_name "^(\\\\textbf|\\\\mathbf)$"))
|
|
||||||
|
|
||||||
((generic_command
|
|
||||||
name:(generic_command_name) @_name
|
|
||||||
.
|
.
|
||||||
arg: (_) @text.uri)
|
arg: (curly_group (_) @text.uri))
|
||||||
(#match? @_name "^(\\\\url|\\\\href)$"))
|
(#match? @_name "^(\\\\url|\\\\href)$"))
|
||||||
|
|
||||||
(ERROR) @error
|
;; General environments
|
||||||
|
|
||||||
[
|
[
|
||||||
"\\begin"
|
"\\begin"
|
||||||
"\\end"
|
"\\end"
|
||||||
] @text.environment
|
] @text.environment
|
||||||
|
|
||||||
(begin
|
(begin
|
||||||
name: (_) @text.environment.name
|
name: (curly_group_text
|
||||||
|
(text) @text.environment.name)
|
||||||
(#not-any-of? @text.environment.name
|
(#not-any-of? @text.environment.name
|
||||||
"displaymath" "displaymath*"
|
"displaymath" "displaymath*"
|
||||||
"equation" "equation*"
|
"equation" "equation*"
|
||||||
|
|
@ -413,7 +392,8 @@
|
||||||
"flalign" "flalign*"))
|
"flalign" "flalign*"))
|
||||||
|
|
||||||
(end
|
(end
|
||||||
name: (_) @text.environment.name
|
name: (curly_group_text
|
||||||
|
(text) @text.environment.name)
|
||||||
(#not-any-of? @text.environment.name
|
(#not-any-of? @text.environment.name
|
||||||
"displaymath" "displaymath*"
|
"displaymath" "displaymath*"
|
||||||
"equation" "equation*"
|
"equation" "equation*"
|
||||||
|
|
@ -425,3 +405,5 @@
|
||||||
"alignat" "alignat*"
|
"alignat" "alignat*"
|
||||||
"gather" "gather*"
|
"gather" "gather*"
|
||||||
"flalign" "flalign*"))
|
"flalign" "flalign*"))
|
||||||
|
|
||||||
|
(ERROR) @error
|
||||||
|
|
|
||||||
|
|
@ -1 +1,9 @@
|
||||||
(comment) @comment
|
[
|
||||||
|
(line_comment)
|
||||||
|
(block_comment)
|
||||||
|
(comment_environment)
|
||||||
|
] @comment
|
||||||
|
|
||||||
|
(pycode_environment
|
||||||
|
code: (source_code) @python
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue