mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
latex: add TSMath that behaves like vimtex math highlighting
This commit is contained in:
parent
ea8c3b2850
commit
0556edf5f3
4 changed files with 35 additions and 7 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue