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

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
pull/3387/head
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*"))
[
(generic_command_name)
"\\newcommand"
"\\renewcommand"
"\\DeclareRobustCommand"
"\\DeclareMathOperator"
"\\newglossaryentry"
"\\caption"
"\\label"
"\\newlabel"
"\\color"
"\\colorbox"
"\\textcolor"
"\\pagecolor"
"\\definecolor"
"\\definecolorset"
"\\newtheorem"
"\\declaretheorem"
"\\newacronym"
] @function.macro
[
"\\ref"
"\\vref"
"\\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"
"\\cite*"
"\\Cite"
"\\nocite"
"\\citet"
"\\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"
"\\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
[ (command_name) @function
"\\gls" (caption
"\\Gls" command: _ @function)
"\\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
(key_value_pair
key: (_) @variable.parameter
value: (_))
[ [
"\\acrshort" (comment)
"\\Acrshort" (line_comment)
"\\ACRshort" (block_comment)
"\\acrshortpl" (comment_environment)
"\\Acrshortpl" ] @comment
"\\ACRshortpl"
"\\acrlong"
"\\Acrlong"
"\\ACRlong"
"\\acrlongpl"
"\\Acrlongpl"
"\\ACRlongpl"
"\\acrfull"
"\\Acrfull"
"\\ACRfull"
"\\acrfullpl"
"\\Acrfullpl"
"\\ACRfullpl"
"\\acs"
"\\Acs"
"\\acsp"
"\\Acsp"
"\\acl"
"\\Acl"
"\\aclp"
"\\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
[ [
"\\usepackage" (brack_group)
"\\documentclass" (brack_group_argc)
"\\input" ] @variable.parameter
"\\include"
"\\subfile"
"\\subfileinclude"
"\\subfileinclude"
"\\includegraphics"
"\\addbibresource"
"\\bibliography"
"\\includesvg"
"\\includeinkscape"
"\\usepgflibrary"
"\\usetikzlibrary"
] @keyword.control.import
[ [(operator) "="] @operator
"\\part"
"\\chapter"
"\\section"
"\\subsection"
"\\subsubsection"
"\\paragraph"
"\\subparagraph"
] @type
"\\item" @punctuation.special "\\item" @punctuation.special
((word) @punctuation.delimiter ((word) @punctuation.delimiter
(#eq? @punctuation.delimiter "&")) (#eq? @punctuation.delimiter "&"))
["$" "\\[" "\\]" "\\(" "\\)"] @punctuation.delimiter ["[" "]" "{" "}"] @punctuation.bracket ; "(" ")" has no syntactical meaning in LaTeX
;; General environments
(begin
command: _ @function.builtin
name: (curly_group_text (text) @function.macro))
(end
command: _ @function.builtin
name: (curly_group_text (text) @function.macro))
;; 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 (_) @constant))
(theorem_definition
command: _ @function.macro
name: (curly_group_text (_) @constant))
(paired_delimiter_definition
command: _ @function.macro
declaration: (curly_group_command_name (_) @function))
(label_definition (label_definition
name: (_) @text.reference) command: _ @function.macro
(label_reference name: (curly_group_text (_) @label))
label: (_) @text.reference) (label_reference_range
(equation_label_reference command: _ @function.macro
label: (_) @text.reference) from: (curly_group_text (_) @label)
to: (curly_group_text (_) @label))
(label_reference (label_reference
label: (_) @text.reference) command: _ @function.macro
names: (curly_group_text_list (_) @label))
(label_number (label_number
label: (_) @text.reference) command: _ @function.macro
name: (curly_group_text (_) @label)
number: (_) @markup.link.label)
(citation (citation
key: (word) @text.reference) command: _ @function.macro
keys: (curly_group_text_list) @string)
(glossary_entry_definition
command: _ @function.macro
name: (curly_group_text (_) @string))
(glossary_entry_reference
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))
(key_val_pair ;; Math
key: (_) @variable.parameter
value: (_)) (displayed_equation) @markup.raw.block
(inline_formula) @markup.raw.inline
(math_environment
(begin
command: _ @function.builtin
name: (curly_group_text (text) @markup.raw)))
(math_environment
(text) @markup.raw)
(math_environment
(end
command: _ @function.builtin
name: (curly_group_text (text) @markup.raw)))
;; Sectioning
(title_declaration
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