diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2021-03-28 21:06:53 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-03-30 19:26:37 +0200 |
| commit | 712cc78a1e7a3576ad21f05e438128e9aa9521c5 (patch) | |
| tree | a48c251445a0dccfc8fa2d09123300582ecd9cc6 | |
| parent | latex: add TSMath that behaves like vimtex math highlighting (diff) | |
| download | nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.tar nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.tar.gz nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.tar.bz2 nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.tar.lz nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.tar.xz nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.tar.zst nvim-treesitter-712cc78a1e7a3576ad21f05e438128e9aa9521c5.zip | |
Add text.reference and text.environment
| -rw-r--r-- | CONTRIBUTING.md | 5 | ||||
| -rw-r--r-- | lua/nvim-treesitter/highlight.lua | 3 | ||||
| -rw-r--r-- | plugin/nvim-treesitter.vim | 3 | ||||
| -rw-r--r-- | queries/latex/folds.scm | 2 | ||||
| -rw-r--r-- | queries/latex/highlights.scm | 64 | ||||
| -rw-r--r-- | queries/rst/highlights.scm | 2 |
6 files changed, 66 insertions, 13 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 748ac745b..cec51bdc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -167,7 +167,10 @@ Mainly for markup languages. @text.title @text.literal @text.uri -@text.math (e.g. for LaTeX math enviroments) +@text.math (e.g. for LaTeX math environments) +@text.environment (e.g. for text environments of markup languages) +@text.environment.name (e.g. for the name/the string indicating the type of text environment) +@text.reference (for footnotes, text references, citations) @text.note @text.warning diff --git a/lua/nvim-treesitter/highlight.lua b/lua/nvim-treesitter/highlight.lua index 96b69eebc..73952db9d 100644 --- a/lua/nvim-treesitter/highlight.lua +++ b/lua/nvim-treesitter/highlight.lua @@ -85,6 +85,9 @@ hlmap["text.title"] = "TSTitle" hlmap["text.literal"] = "TSLiteral" hlmap["text.uri"] = "TSURI" hlmap["text.math"] = "TSMath" +hlmap["text.reference"] = "TSTextReference" +hlmap["text.environment"] = "TSEnviroment" +hlmap["text.environment.name"] = "TSEnviromentName" hlmap["text.note"] = "TSNote" hlmap["text.warning"] = "TSWarning" diff --git a/plugin/nvim-treesitter.vim b/plugin/nvim-treesitter.vim index fc24ef392..b9652d01a 100644 --- a/plugin/nvim-treesitter.vim +++ b/plugin/nvim-treesitter.vim @@ -77,6 +77,9 @@ 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 TSTextReference Constant +highlight default link TSEnviroment Macro +highlight default link TSEnviromentName Normal highlight default link TSTitle Title highlight default link TSLiteral String highlight default link TSURI Underlined diff --git a/queries/latex/folds.scm b/queries/latex/folds.scm index f0f9207b8..fb5c71767 100644 --- a/queries/latex/folds.scm +++ b/queries/latex/folds.scm @@ -1,5 +1,6 @@ [ (chapter) + (part) (section) (subsection) (subsubsection) @@ -7,4 +8,5 @@ (subparagraph) (environment) + (displayed_equation) ] @fold diff --git a/queries/latex/highlights.scm b/queries/latex/highlights.scm index dc1cb0740..bd89c4a45 100644 --- a/queries/latex/highlights.scm +++ b/queries/latex/highlights.scm @@ -8,7 +8,7 @@ ((environment (begin name: (word) @_env)) @text.math - (#match? @_env "^(displaymath|eqn|eqnarray|align)[*]?$")) + (#match? @_env "^(displaymath|equation|multline|eqnarray|align|array|split)[*]?$")) ;; This at the begining of the file would be the alternative to highlight ;; only the interior of the environment @@ -20,12 +20,29 @@ [ (generic_command_name) - "\\begin" - "\\end" "\\newcommand" "\\renewcommand" "\\DeclareRobustCommand" + "\\DeclareMathOperator" + "\\newglossaryentry" "\\caption" + "\\cite" + "\\label" + "\\newlabel" + "\\label" + "\\ref" + "\\cref" + "\\eqref" + "\\color" + "\\colorbox" + "\\textcolor" + "\\pagecolor" + "\\definecolor" + "\\definecolorset" + "\\newtheorem" + "\\declaretheorem" + "\\newacronym" + "\\newglossaryentry" ] @function.macro (comment) @comment @@ -38,6 +55,7 @@ "\\usepackage" "\\documentclass" "\\input" + "\\include" "\\subfile" "\\subfileinclude" "\\subfileinclude" @@ -51,6 +69,7 @@ ] @include [ + "\\part" "\\chapter" "\\section" "\\subsection" @@ -64,22 +83,34 @@ ((word) @punctuation.delimiter (#eq? @punctuation.delimiter "&")) -[ - (label_definition) - (label_reference) - (equation_label_reference) - (label_number) -] @label +["$" "\\[" "\\]" "\\(" "\\)"] @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 +["[" "]" "{" "}"] @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) @@ -128,8 +159,19 @@ ((generic_command name:(generic_command_name) @_name . - arg: (_) @text.url) + arg: (_) @text.uri) (#match? @_name "^(\\url|\\href)$")) (ERROR) @error +[ + "\\begin" + "\\end" +] @text.environment + +(begin + name: (_) @text.environment.name + (#not-match? @text.environment.name "^(displaymath|equation|multline|eqnarray|align|array|split)[*]?$")) +(end + name: (_) @text.environment.name + (#not-match? @text.environment.name "^(displaymath|equation|multline|eqnarray|align|array|split)[*]?$")) diff --git a/queries/rst/highlights.scm b/queries/rst/highlights.scm index c153677f4..470fa80f9 100644 --- a/queries/rst/highlights.scm +++ b/queries/rst/highlights.scm @@ -127,7 +127,7 @@ (footnote_reference) (citation_reference) (reference) -] @constant +] @text.reference ;; Others |
