Update tree-sitter-latex and highlights (#3370)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
imgbot
Erasin 2 years ago committed by GitHub
parent 598aa7c424
commit 921027fb32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,7 +54,7 @@
| jsx | ✓ | ✓ | ✓ | `typescript-language-server` | | jsx | ✓ | ✓ | ✓ | `typescript-language-server` |
| julia | ✓ | | | `julia` | | julia | ✓ | | | `julia` |
| kotlin | ✓ | | | `kotlin-language-server` | | kotlin | ✓ | | | `kotlin-language-server` |
| latex | ✓ | | | `texlab` | | latex | ✓ | | | `texlab` |
| lean | ✓ | | | `lean` | | lean | ✓ | | | `lean` |
| ledger | ✓ | | | | | ledger | ✓ | | | |
| llvm | ✓ | ✓ | ✓ | | | llvm | ✓ | ✓ | ✓ | |

@ -537,7 +537,7 @@ indent = { tab-width = 4, unit = "\t" }
[[grammar]] [[grammar]]
name = "latex" name = "latex"
source = { git = "https://github.com/latex-lsp/tree-sitter-latex", rev = "7f720661de5316c0f8fee956526d4002fa1086d8" } source = { git = "https://github.com/latex-lsp/tree-sitter-latex", rev = "b3b2cf27f33e71438ebe46934900b1153901c6f2" }
[[language]] [[language]]
name = "lean" name = "lean"

@ -1,410 +1,235 @@
;; Math ;; General syntax
[ (ERROR) @error
(displayed_equation)
(inline_formula)
] @text.math
;; This highlights the whole environment like vimtex does
((environment
(begin
name: (word) @_env)) @text.math
(#any-of? @_env
"displaymath" "displaymath*"
"equation" "equation*"
"multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
[ (command_name) @function
(generic_command_name) (caption
"\\newcommand" command: _ @function)
"\\renewcommand"
"\\DeclareRobustCommand"
"\\DeclareMathOperator"
"\\newglossaryentry"
"\\caption"
"\\label"
"\\newlabel"
"\\color"
"\\colorbox"
"\\textcolor"
"\\pagecolor"
"\\definecolor"
"\\definecolorset"
"\\newtheorem"
"\\declaretheorem"
"\\newacronym"
] @function.macro
[ (key_value_pair
"\\ref" key: (_) @variable.parameter
"\\vref" value: (_))
"\\Vref"
"\\autoref"
"\\pageref"
"\\cref"
"\\Cref"
"\\cref*"
"\\Cref*"
"\\namecref"
"\\nameCref"
"\\lcnamecref"
"\\namecrefs"
"\\nameCrefs"
"\\lcnamecrefs"
"\\labelcref"
"\\labelcpageref"
"\\crefrange"
"\\crefrange"
"\\Crefrange"
"\\Crefrange"
"\\crefrange*"
"\\crefrange*"
"\\Crefrange*"
"\\Crefrange*"
] @function.macro
[ [
"\\cite" (comment)
"\\cite*" (line_comment)
"\\Cite" (block_comment)
"\\nocite" (comment_environment)
"\\citet" ] @comment
"\\citep"
"\\citet*"
"\\citep*"
"\\citeauthor"
"\\citeauthor*"
"\\Citeauthor"
"\\Citeauthor*"
"\\citetitle"
"\\citetitle*"
"\\citeyear"
"\\citeyear*"
"\\citedate"
"\\citedate*"
"\\citeurl"
"\\fullcite"
"\\citeyearpar"
"\\citealt"
"\\citealp"
"\\citetext"
"\\parencite"
"\\parencite*"
"\\Parencite"
"\\footcite"
"\\footfullcite"
"\\footcitetext"
"\\textcite"
"\\Textcite"
"\\smartcite"
"\\Smartcite"
"\\supercite"
"\\autocite"
"\\Autocite"
"\\autocite*"
"\\Autocite*"
"\\volcite"
"\\Volcite"
"\\pvolcite"
"\\Pvolcite"
"\\fvolcite"
"\\ftvolcite"
"\\svolcite"
"\\Svolcite"
"\\tvolcite"
"\\Tvolcite"
"\\avolcite"
"\\Avolcite"
"\\notecite"
"\\notecite"
"\\pnotecite"
"\\Pnotecite"
"\\fnotecite"
] @function.macro
[ [
"\\ref" (brack_group)
"\\vref" (brack_group_argc)
"\\Vref" ] @variable.parameter
"\\autoref"
"\\pageref"
"\\cref"
"\\Cref"
"\\cref*"
"\\Cref*"
"\\namecref"
"\\nameCref"
"\\lcnamecref"
"\\namecrefs"
"\\nameCrefs"
"\\lcnamecrefs"
"\\labelcref"
"\\labelcpageref"
] @function.macro
[(operator) "="] @operator
[ "\\item" @punctuation.special
"\\crefrange"
"\\crefrange"
"\\Crefrange"
"\\Crefrange"
"\\crefrange*"
"\\crefrange*"
"\\Crefrange*"
"\\Crefrange*"
] @function.macro
((word) @punctuation.delimiter
(#eq? @punctuation.delimiter "&"))
[ ["[" "]" "{" "}"] @punctuation.bracket ; "(" ")" has no syntactical meaning in LaTeX
"\\gls"
"\\Gls"
"\\GLS"
"\\glspl"
"\\Glspl"
"\\GLSpl"
"\\glsdisp"
"\\glslink"
"\\glstext"
"\\Glstext"
"\\GLStext"
"\\glsfirst"
"\\Glsfirst"
"\\GLSfirst"
"\\glsplural"
"\\Glsplural"
"\\GLSplural"
"\\glsfirstplural"
"\\Glsfirstplural"
"\\GLSfirstplural"
"\\glsname"
"\\Glsname"
"\\GLSname"
"\\glssymbol"
"\\Glssymbol"
"\\glsdesc"
"\\Glsdesc"
"\\GLSdesc"
"\\glsuseri"
"\\Glsuseri"
"\\GLSuseri"
"\\glsuserii"
"\\Glsuserii"
"\\GLSuserii"
"\\glsuseriii"
"\\Glsuseriii"
"\\GLSuseriii"
"\\glsuseriv"
"\\Glsuseriv"
"\\GLSuseriv"
"\\glsuserv"
"\\Glsuserv"
"\\GLSuserv"
"\\glsuservi"
"\\Glsuservi"
"\\GLSuservi"
] @function.macro
;; General environments
(begin
command: _ @function.builtin
name: (curly_group_text (text) @function.macro))
[ (end
"\\acrshort" command: _ @function.builtin
"\\Acrshort" name: (curly_group_text (text) @function.macro))
"\\ACRshort"
"\\acrshortpl" ;; Definitions and references
"\\Acrshortpl" (new_command_definition
"\\ACRshortpl" command: _ @function.macro
"\\acrlong" declaration: (curly_group_command_name (_) @function))
"\\Acrlong" (old_command_definition
"\\ACRlong" command: _ @function.macro
"\\acrlongpl" declaration: (_) @function)
"\\Acrlongpl" (let_command_definition
"\\ACRlongpl" command: _ @function.macro
"\\acrfull" declaration: (_) @function)
"\\Acrfull"
"\\ACRfull" (environment_definition
"\\acrfullpl" command: _ @function.macro
"\\Acrfullpl" name: (curly_group_text (_) @constant))
"\\ACRfullpl"
"\\acs" (theorem_definition
"\\Acs" command: _ @function.macro
"\\acsp" name: (curly_group_text (_) @constant))
"\\Acsp"
"\\acl" (paired_delimiter_definition
"\\Acl" command: _ @function.macro
"\\aclp" declaration: (curly_group_command_name (_) @function))
"\\Aclp"
"\\acf"
"\\Acf"
"\\acfp"
"\\Acfp"
"\\ac"
"\\Ac"
"\\acp"
"\\glsentrylong"
"\\Glsentrylong"
"\\glsentrylongpl"
"\\Glsentrylongpl"
"\\glsentryshort"
"\\Glsentryshort"
"\\glsentryshortpl"
"\\Glsentryshortpl"
"\\glsentryfullpl"
"\\Glsentryfullpl"
] @function.macro
(comment) @comment
(bracket_group) @variable.parameter
[(math_operator) "="] @operator
[ (label_definition
"\\usepackage" command: _ @function.macro
"\\documentclass" name: (curly_group_text (_) @label))
"\\input" (label_reference_range
"\\include" command: _ @function.macro
"\\subfile" from: (curly_group_text (_) @label)
"\\subfileinclude" to: (curly_group_text (_) @label))
"\\subfileinclude" (label_reference
"\\includegraphics" command: _ @function.macro
"\\addbibresource" names: (curly_group_text_list (_) @label))
"\\bibliography" (label_number
"\\includesvg" command: _ @function.macro
"\\includeinkscape" name: (curly_group_text (_) @label)
"\\usepgflibrary" number: (_) @markup.link.label)
"\\usetikzlibrary"
] @keyword.control.import
[ (citation
"\\part" command: _ @function.macro
"\\chapter" keys: (curly_group_text_list) @string)
"\\section"
"\\subsection" (glossary_entry_definition
"\\subsubsection" command: _ @function.macro
"\\paragraph" name: (curly_group_text (_) @string))
"\\subparagraph" (glossary_entry_reference
] @type command: _ @function.macro
name: (curly_group_text (_) @string))
(acronym_definition
command: _ @function.macro
name: (curly_group_text (_) @string))
(acronym_reference
command: _ @function.macro
name: (curly_group_text (_) @string))
(color_definition
command: _ @function.macro
name: (curly_group_text (_) @string))
(color_reference
command: _ @function.macro
name: (curly_group_text (_) @string))
"\\item" @punctuation.special ;; Math
((word) @punctuation.delimiter (displayed_equation) @markup.raw.block
(#eq? @punctuation.delimiter "&")) (inline_formula) @markup.raw.inline
["$" "\\[" "\\]" "\\(" "\\)"] @punctuation.delimiter (math_environment
(begin
command: _ @function.builtin
name: (curly_group_text (text) @markup.raw)))
(label_definition (math_environment
name: (_) @text.reference) (text) @markup.raw)
(label_reference
label: (_) @text.reference)
(equation_label_reference
label: (_) @text.reference)
(label_reference
label: (_) @text.reference)
(label_number
label: (_) @text.reference)
(citation (math_environment
key: (word) @text.reference) (end
command: _ @function.builtin
name: (curly_group_text (text) @markup.raw)))
(key_val_pair ;; Sectioning
key: (_) @variable.parameter (title_declaration
value: (_)) command: _ @namespace
options: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
["[" "]" "{" "}"] @punctuation.bracket ;"(" ")" is has no special meaning in LaTeX (author_declaration
command: _ @namespace
authors: (curly_group_author_list
((author)+ @markup.heading)))
(chapter (chapter
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
(part (part
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
(section (section
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
(subsection (subsection
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
(subsubsection (subsubsection
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
(paragraph (paragraph
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
(subparagraph (subparagraph
text: (brace_group) @markup.heading) command: _ @namespace
toc: (brack_group (_) @markup.heading)?
text: (curly_group (_) @markup.heading))
((environment ;; Beamer frames
(generic_environment
(begin (begin
name: (word) @_frame) name: (curly_group_text
(brace_group (text) @markup.heading)
child: (text) @markup.heading)) (#any-of? @markup.heading "frame"))
(#eq? @_frame "frame")) .
(curly_group (_) @markup.heading))
((generic_command ((generic_command
name:(generic_command_name) @_name command: (command_name) @_name
arg: (brace_group arg: (curly_group
(text) @markup.heading)) (text) @markup.heading))
(#eq? @_name "\\frametitle")) (#eq? @_name "\\frametitle"))
;; Formatting ;; Formatting
((generic_command ((generic_command
name:(generic_command_name) @_name command: (command_name) @_name
arg: (_) @markup.italic) arg: (curly_group (_) @markup.italic))
(#eq? @_name "\\emph")) (#eq? @_name "\\emph"))
((generic_command ((generic_command
name:(generic_command_name) @_name command: (command_name) @_name
arg: (_) @markup.italic) arg: (curly_group (_) @markup.italic))
(#match? @_name "^(\\\\textit|\\\\mathit)$")) (#match? @_name "^(\\\\textit|\\\\mathit)$"))
((generic_command ((generic_command
name:(generic_command_name) @_name command: (command_name) @_name
arg: (_) @markup.bold) arg: (curly_group (_) @markup.bold))
(#match? @_name "^(\\\\textbf|\\\\mathbf)$")) (#match? @_name "^(\\\\textbf|\\\\mathbf)$"))
((generic_command ((generic_command
name:(generic_command_name) @_name command: (command_name) @_name
. .
arg: (_) @markup.link.url) arg: (curly_group (_) @markup.link.uri))
(#match? @_name "^(\\\\url|\\\\href)$")) (#match? @_name "^(\\\\url|\\\\href)$"))
(ERROR) @error ;; File inclusion commands
(class_include
[ command: _ @keyword.storage.type
"\\begin" path: (curly_group_path) @string)
"\\end"
] @text.environment (package_include
command: _ @keyword.storage.type
(begin paths: (curly_group_path_list) @string)
name: (_) @text.environment.name
(#not-any-of? @text.environment.name (latex_include
"displaymath" "displaymath*" command: _ @keyword.control.import
"equation" "equation*" path: (curly_group_path) @string)
"multline" "multline*" (import_include
"eqnarray" "eqnarray*" command: _ @keyword.control.import
"align" "align*" directory: (curly_group_path) @string
"array" "array*" file: (curly_group_path) @string)
"split" "split*"
"alignat" "alignat*" (bibtex_include
"gather" "gather*" command: _ @keyword.control.import
"flalign" "flalign*")) path: (curly_group_path) @string)
(biblatex_include
(end "\\addbibresource" @include
name: (_) @text.environment.name glob: (curly_group_glob_pattern) @string.regex)
(#not-any-of? @text.environment.name
"displaymath" "displaymath*" (graphics_include
"equation" "equation*" command: _ @keyword.control.import
"multline" "multline*" path: (curly_group_path) @string)
"eqnarray" "eqnarray*" (tikz_library_import
"align" "align*" command: _ @keyword.control.import
"array" "array*" paths: (curly_group_path_list) @string)
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))

@ -0,0 +1,13 @@
[
(generic_command)
] @function.around
[
(chapter)
(part)
(section)
(subsection)
(subsubsection)
(paragraph)
(subparagraph)
] @class.around
Loading…
Cancel
Save