aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2024-09-24 08:41:46 -0700
committerChristian Clason <ch.clason+github@icloud.com>2025-03-02 18:38:13 +0100
commit65c7033cbe75825c4cc948b71aba9a6d7a14540d (patch)
tree864da0d8da2918f5e7abdc46f57f78cd5a1f244a /runtime/doc
parent59c328bc88ccb1d331c3e63768bb11c3555b1f57 (diff)
downloadrneovim-65c7033cbe75825c4cc948b71aba9a6d7a14540d.tar.gz
rneovim-65c7033cbe75825c4cc948b71aba9a6d7a14540d.tar.bz2
rneovim-65c7033cbe75825c4cc948b71aba9a6d7a14540d.zip
feat(comment): allow commentstring to be determined from node metadata
**Problem:** Some weird languages have different comment syntax depending on the location in the code, and we do not have a way to determine the correct `commentstring` for these special cases. **Solution:** Allow queries to specify `commentstring` values in metadata, allowing users/`nvim-treesitter` to provide a better commenting experience without hugely increasing the scope of the code in core.
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/news.txt4
-rw-r--r--runtime/doc/treesitter.txt13
2 files changed, 17 insertions, 0 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 1a6537fa8d..a131934a8e 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -359,6 +359,10 @@ PLUGINS
• spelling_language property is now supported.
• 'inccommand' incremental preview can run on 'nomodifiable' buffers and
restores their 'modifiable' state
+• Commenting
+ • 'commentstring' values can now be specified in a Treesitter capture's
+ `bo.commentstring` metadata field, providing finer grained support for
+ languages like `JSX`.
STARTUP
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 5916ec9371..3918188f1b 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -531,6 +531,19 @@ attribute: >query
((super_important_node) @superimportant (#set! priority 105))
<
+ *treesitter-highlight-commentstring*
+Treesitter highlighting supports finer-grained 'commentstring's, used by the
+built-in |commenting| plugin. When the cursor is within a node that sets the
+`bo.commentstring` metadata property (|treesitter-directive-set!|), that
+property defines the comment delimiter (where "innermost wins"). This is
+useful for languages like `JSX` that have different comment syntax depending
+on the code region, for example: >query
+
+ ((jsx_element) @_tag (#set! @_tag bo.commentstring "{/* %s */}"))
+<
+When multiple captures set this metadata over a region, only the innermost
+(most specific) one is applied to a given area.
+
==============================================================================
TREESITTER LANGUAGE INJECTIONS *treesitter-language-injections*
<