From 8ba047e33fe3a10765c593c810d54b5e3bb906e9 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sun, 24 Nov 2024 14:46:20 +0100 Subject: feat(treesitter): vertical conceal support for highlighter TSHighlighter now places marks for conceal_lines metadata. A new internal decor provider callback _on_conceal_line was added that instructs the highlighter to place conceal_lines marks whenever the editor needs to know whether a line is concealed. The bundled markdown queries use conceal_lines metadata to conceal code block fence lines. --- runtime/doc/news.txt | 2 ++ runtime/doc/treesitter.txt | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 25f6255ed3..17de99730a 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -406,6 +406,8 @@ TREESITTER • |LanguageTree:is_valid()| now accepts a range parameter to narrow the scope of the validity check. • |:InspectTree| now shows which nodes are missing. +• Bundled markdown highlight queries use `conceal_lines` metadata to conceal + code block fence lines vertically. TUI diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 344bd37ddd..db23576192 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -492,10 +492,10 @@ capture marks comments as to be checked: >query There is also `@nospell` which disables spellchecking regions with `@spell`. *treesitter-highlight-conceal* -Treesitter highlighting supports |conceal| via the `conceal` metadata. By -convention, nodes to be concealed are captured as `@conceal`, but any capture -can be used. For example, the following query can be used to hide code block -delimiters in Markdown: >query +Treesitter highlighting supports |conceal| via the `conceal` and `conceal_lines` +metadata. By convention, nodes to be concealed are captured as `@conceal`, but +any capture can be used. For example, the following query can be used to hide +code block delimiters in Markdown: >query ((fenced_code_block_delimiter) @conceal (#set! conceal "")) < @@ -506,7 +506,13 @@ still highlighted the same as other operators: >query "!=" @operator (#set! conceal "≠") < -Conceals specified in this way respect 'conceallevel'. +To conceal an entire line (do not draw it at all), a query with `conceal_lines` +metadata can be used: >query + + ((comment) @comment @spell + (#set! conceal_lines "")) +< +Conceals specified in this way respect 'conceallevel' and 'concealcursor'. Note that although you can use any string for `conceal`, only the first character will be used: >query -- cgit