Add latex

pull/281/head
Ivan Tham 3 years ago committed by Blaž Hrastnik
parent d1c8a74771
commit a364d6c383

5
.gitmodules vendored

@ -89,3 +89,8 @@
[submodule "helix-syntax/languages/tree-sitter-nix"]
path = helix-syntax/languages/tree-sitter-nix
url = https://github.com/cstrahan/tree-sitter-nix
shallow = true
[submodule "helix-syntax/languages/tree-sitter-latex"]
path = helix-syntax/languages/tree-sitter-latex
url = https://github.com/latex-lsp/tree-sitter-latex
shallow = true

@ -0,0 +1 @@
Subproject commit 7f720661de5316c0f8fee956526d4002fa1086d8

@ -80,6 +80,7 @@ mk_langs!(
(Java, tree_sitter_java),
(Json, tree_sitter_json),
(Julia, tree_sitter_julia),
(Latex, tree_sitter_latex),
(Nix, tree_sitter_nix),
(Php, tree_sitter_php),
(Python, tree_sitter_python),

@ -156,6 +156,15 @@ roots = []
indent = { tab-width = 2, unit = " " }
[[language]]
name = "latex"
scope = "source.tex"
injection-regex = "tex"
file-types = ["tex"]
roots = []
indent = { tab-width = 4, unit = "\t" }
# [[language]]
# name = "haskell"
# scope = "source.haskell"

@ -0,0 +1,12 @@
[
(chapter)
(part)
(section)
(subsection)
(subsubsection)
(paragraph)
(subparagraph)
(environment)
(displayed_equation)
] @fold

@ -0,0 +1,410 @@
;; Math
[
(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
[
"\\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
[
"\\acrshort"
"\\Acrshort"
"\\ACRshort"
"\\acrshortpl"
"\\Acrshortpl"
"\\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) @parameter
[(math_operator) "="] @operator
[
"\\usepackage"
"\\documentclass"
"\\input"
"\\include"
"\\subfile"
"\\subfileinclude"
"\\subfileinclude"
"\\includegraphics"
"\\addbibresource"
"\\bibliography"
"\\includesvg"
"\\includeinkscape"
"\\usepgflibrary"
"\\usetikzlibrary"
] @include
[
"\\part"
"\\chapter"
"\\section"
"\\subsection"
"\\subsubsection"
"\\paragraph"
"\\subparagraph"
] @type
"\\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
text: (brace_group) @text.title)
(part
text: (brace_group) @text.title)
(section
text: (brace_group) @text.title)
(subsection
text: (brace_group) @text.title)
(subsubsection
text: (brace_group) @text.title)
(paragraph
text: (brace_group) @text.title)
(subparagraph
text: (brace_group) @text.title)
((environment
(begin
name: (word) @_frame)
(brace_group
child: (text) @text.title))
(#eq? @_frame "frame"))
((generic_command
name:(generic_command_name) @_name
arg: (brace_group
(text) @text.title))
(#eq? @_name "\\frametitle"))
;; Formatting
((generic_command
name:(generic_command_name) @_name
arg: (_) @text.emphasis)
(#eq? @_name "\\emph"))
((generic_command
name:(generic_command_name) @_name
arg: (_) @text.emphasis)
(#match? @_name "^(\\\\textit|\\\\mathit)$"))
((generic_command
name:(generic_command_name) @_name
arg: (_) @text.strong)
(#match? @_name "^(\\\\textbf|\\\\mathbf)$"))
((generic_command
name:(generic_command_name) @_name
.
arg: (_) @text.uri)
(#match? @_name "^(\\\\url|\\\\href)$"))
(ERROR) @error
[
"\\begin"
"\\end"
] @text.environment
(begin
name: (_) @text.environment.name
(#not-any-of? @text.environment.name
"displaymath" "displaymath*"
"equation" "equation*"
"multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
(end
name: (_) @text.environment.name
(#not-any-of? @text.environment.name
"displaymath" "displaymath*"
"equation" "equation*"
"multline" "multline*"
"eqnarray" "eqnarray*"
"align" "align*"
"array" "array*"
"split" "split*"
"alignat" "alignat*"
"gather" "gather*"
"flalign" "flalign*"))
Loading…
Cancel
Save