diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2021-03-28 01:42:47 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-03-30 19:26:37 +0200 |
| commit | 0556edf5f385d95c0f8330e6607ade3b9710adc6 (patch) | |
| tree | d716d2c57de5d369c4ec18e0d9138925108b4a82 | |
| parent | feat: Add Latex basic highlights and folds (diff) | |
| download | nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.tar nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.tar.gz nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.tar.bz2 nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.tar.lz nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.tar.xz nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.tar.zst nvim-treesitter-0556edf5f385d95c0f8330e6607ade3b9710adc6.zip | |
latex: add TSMath that behaves like vimtex math highlighting
| -rw-r--r-- | CONTRIBUTING.md | 1 | ||||
| -rw-r--r-- | lua/nvim-treesitter/highlight.lua | 1 | ||||
| -rw-r--r-- | plugin/nvim-treesitter.vim | 1 | ||||
| -rw-r--r-- | queries/latex/highlights.scm | 39 |
4 files changed, 35 insertions, 7 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53d3ab171..748ac745b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -167,6 +167,7 @@ Mainly for markup languages. @text.title @text.literal @text.uri +@text.math (e.g. for LaTeX math enviroments) @text.note @text.warning diff --git a/lua/nvim-treesitter/highlight.lua b/lua/nvim-treesitter/highlight.lua index 6f9208eeb..96b69eebc 100644 --- a/lua/nvim-treesitter/highlight.lua +++ b/lua/nvim-treesitter/highlight.lua @@ -84,6 +84,7 @@ hlmap["text.strike"] = "TSStrike" hlmap["text.title"] = "TSTitle" hlmap["text.literal"] = "TSLiteral" hlmap["text.uri"] = "TSURI" +hlmap["text.math"] = "TSMath" hlmap["text.note"] = "TSNote" hlmap["text.warning"] = "TSWarning" diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim index d9acaebb0..fc24ef392 100644 --- a/plugin/nvim-treesitter.vim +++ b/plugin/nvim-treesitter.vim @@ -76,6 +76,7 @@ highlight default TSStrong term=bold cterm=bold gui=bold highlight default TSEmphasis term=italic cterm=italic gui=italic highlight default TSUnderline term=underline cterm=underline gui=underline highlight default TSStrike term=strikethrough cterm=strikethrough gui=strikethrough +highlight default link TSMath Special highlight default link TSTitle Title highlight default link TSLiteral String highlight default link TSURI Underlined diff --git a/queries/latex/highlights.scm b/queries/latex/highlights.scm index cea10cb31..dc1cb0740 100644 --- a/queries/latex/highlights.scm +++ b/queries/latex/highlights.scm @@ -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) "\\begin" @@ -5,6 +25,7 @@ "\\newcommand" "\\renewcommand" "\\DeclareRobustCommand" + "\\caption" ] @function.macro (comment) @comment @@ -38,6 +59,11 @@ "\\subparagraph" ] @type +"\\item" @punctuation.special + +((word) @punctuation.delimiter +(#eq? @punctuation.delimiter "&")) + [ (label_definition) (label_reference) @@ -99,12 +125,11 @@ arg: (_) @text.strong) (#match? @_name "^(\\textbf|\\mathbf)$")) -(ERROR) @error +((generic_command + name:(generic_command_name) @_name + . + arg: (_) @text.url) + (#match? @_name "^(\\url|\\href)$")) -;; Controversial -; Add @text.bullet? -"\\item" @punctuation.special +(ERROR) @error -;; Math (TODO) -;(displayed_equation) -;(inline_formula) |
