latex: add TSMath that behaves like vimtex math highlighting

This commit is contained in:
Stephan Seitz 2021-03-28 01:42:47 +01:00 committed by Stephan Seitz
parent ea8c3b2850
commit 0556edf5f3
4 changed files with 35 additions and 7 deletions

View file

@ -167,6 +167,7 @@ Mainly for markup languages.
@text.title @text.title
@text.literal @text.literal
@text.uri @text.uri
@text.math (e.g. for LaTeX math enviroments)
@text.note @text.note
@text.warning @text.warning

View file

@ -84,6 +84,7 @@ hlmap["text.strike"] = "TSStrike"
hlmap["text.title"] = "TSTitle" hlmap["text.title"] = "TSTitle"
hlmap["text.literal"] = "TSLiteral" hlmap["text.literal"] = "TSLiteral"
hlmap["text.uri"] = "TSURI" hlmap["text.uri"] = "TSURI"
hlmap["text.math"] = "TSMath"
hlmap["text.note"] = "TSNote" hlmap["text.note"] = "TSNote"
hlmap["text.warning"] = "TSWarning" hlmap["text.warning"] = "TSWarning"

View file

@ -76,6 +76,7 @@ highlight default TSStrong term=bold cterm=bold gui=bold
highlight default TSEmphasis term=italic cterm=italic gui=italic highlight default TSEmphasis term=italic cterm=italic gui=italic
highlight default TSUnderline term=underline cterm=underline gui=underline highlight default TSUnderline term=underline cterm=underline gui=underline
highlight default TSStrike term=strikethrough cterm=strikethrough gui=strikethrough highlight default TSStrike term=strikethrough cterm=strikethrough gui=strikethrough
highlight default link TSMath Special
highlight default link TSTitle Title highlight default link TSTitle Title
highlight default link TSLiteral String highlight default link TSLiteral String
highlight default link TSURI Underlined highlight default link TSURI Underlined

View file

@ -1,3 +1,23 @@
;; Math
[
(displayed_equation)
(inline_formula)
] @text.math
;; This highlights the whole environment like vimtex does
((environment
(begin
name: (word) @_env)) @text.math
(#match? @_env "^(displaymath|eqn|eqnarray|align)[*]?$"))
;; This at the begining of the file would be the alternative to highlight
;; only the interior of the environment
;((environment
;(begin
;name: (word) @_env) @none
;(end) @none) @text.math
;(#match? @_env "^(displaymath|eqn|eqnarray)[*]?$"))
[ [
(generic_command_name) (generic_command_name)
"\\begin" "\\begin"
@ -5,6 +25,7 @@
"\\newcommand" "\\newcommand"
"\\renewcommand" "\\renewcommand"
"\\DeclareRobustCommand" "\\DeclareRobustCommand"
"\\caption"
] @function.macro ] @function.macro
(comment) @comment (comment) @comment
@ -38,6 +59,11 @@
"\\subparagraph" "\\subparagraph"
] @type ] @type
"\\item" @punctuation.special
((word) @punctuation.delimiter
(#eq? @punctuation.delimiter "&"))
[ [
(label_definition) (label_definition)
(label_reference) (label_reference)
@ -99,12 +125,11 @@
arg: (_) @text.strong) arg: (_) @text.strong)
(#match? @_name "^(\\textbf|\\mathbf)$")) (#match? @_name "^(\\textbf|\\mathbf)$"))
((generic_command
name:(generic_command_name) @_name
.
arg: (_) @text.url)
(#match? @_name "^(\\url|\\href)$"))
(ERROR) @error (ERROR) @error
;; Controversial
; Add @text.bullet?
"\\item" @punctuation.special
;; Math (TODO)
;(displayed_equation)
;(inline_formula)