diff options
| -rw-r--r-- | CONTRIBUTING.md | 17 | ||||
| -rw-r--r-- | queries/c/highlights.scm | 6 | ||||
| -rw-r--r-- | queries/markdown/highlights.scm | 8 | ||||
| -rw-r--r-- | queries/vimdoc/highlights.scm | 2 |
4 files changed, 19 insertions, 14 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d1a16a0b..f2e96bc1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,9 +82,7 @@ you can mark the language as optional (by putting it between parenthesis). ### Highlights -As languages differ quite a lot, here is a set of captures available to you when building a `highlights.scm` query. -One important thing to note is that many of these capture groups are not supported by `neovim` for now, and will not have any -effect on highlighting. We will work on improving highlighting in the near future though. +As languages differ quite a lot, here is a set of captures available to you when building a `highlights.scm` query. Note that your colorscheme needs to define (or link) these captures as highlight groups. #### Misc @@ -196,7 +194,6 @@ Mainly for markup languages. @text.underline ; underlined text @text.strike ; strikethrough text @text.title ; text that is part of a title -@text.literal ; literal or verbatim text (e.g., inline code) @text.quote ; text quotations @text.uri ; URIs (e.g. hyperlinks) @text.math ; math environments (e.g. `$ ... $` in LaTeX) @@ -204,6 +201,10 @@ Mainly for markup languages. @text.environment.name ; text indicating the type of an environment @text.reference ; text references, footnotes, citations, etc. +@text.literal ; literal or verbatim text (e.g., inline code) +@text.literal.block ; literal or verbatim text as a stand-alone block + ; (use priority 90 for blocks with injections) + @text.todo ; todo notes @text.note ; info notes @text.warning ; warning notes @@ -238,6 +239,14 @@ Used for XML-like tags. @nospell ; for defining regions that should NOT be spellchecked ``` +#### Priority + +Captures can be assigned a priority to control precedence of highlights via the +`#set! "priority" <number>` directive (see `:h treesitter-highlight-priority`). +The default priority for treesitter highlights is `100`; queries should only +set priorities between `90` and `120`, to avoid conflict with other sources of +highlighting (such as diagnostics or LSP semantic tokens). + ### Locals Note: pay specific attention to the captures here as they are a bit different to diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm index 523a79240..b5dad2ae2 100644 --- a/queries/c/highlights.scm +++ b/queries/c/highlights.scm @@ -112,10 +112,8 @@ (number_literal) @number (char_literal) @character -[ - (preproc_arg) - (preproc_defined) -] @function.macro +((preproc_arg) @function.macro (#set! "priority" 90)) +(preproc_defined) @function.macro (((field_expression (field_identifier) @property)) @_parent diff --git a/queries/markdown/highlights.scm b/queries/markdown/highlights.scm index 8867a4b7f..e78d233cc 100644 --- a/queries/markdown/highlights.scm +++ b/queries/markdown/highlights.scm @@ -9,11 +9,9 @@ (atx_heading (atx_h5_marker) @text.title.5.marker (inline) @text.title.5) (atx_heading (atx_h6_marker) @text.title.6.marker (inline) @text.title.6) -[ - (link_title) - (indented_code_block) - (fenced_code_block) -] @text.literal +(link_title) @text.literal +(indented_code_block) @text.literal.block +((fenced_code_block) @text.literal.block (#set! "priority" 90)) (info_string) @label diff --git a/queries/vimdoc/highlights.scm b/queries/vimdoc/highlights.scm index e0dce49b2..c52333df1 100644 --- a/queries/vimdoc/highlights.scm +++ b/queries/vimdoc/highlights.scm @@ -15,7 +15,7 @@ (codespan "`" @conceal (#set! conceal "") text: (_) @text.literal) -(codeblock) @text.literal +((codeblock) @text.literal.block (#set! "priority" 90)) (codeblock [">" (language)] @conceal (#set! conceal "")) (block |
