Skip to content

Commit

Permalink
Updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
HiPhish committed Sep 26, 2024
1 parent b334c62 commit a026d4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ is based on `Keep a Changelog`_ and this project adheres to `Semantic
Versioning`_.


Unreleased
##########

Fixed
=====

- Highlighting wrong in global strategy after making changes inside a nested
node

Changed
=======

- Queries no longer need the `@sentinel` capture group


[0.6.2] - 2024-09-26
####################

Expand Down
18 changes: 6 additions & 12 deletions doc/rainbow-delimiters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,12 @@ The queries need to define the following capture groups:
The entire delimited node.
- `@delimiter`
Any delimiter you want to highlight in the current `@container`.
- `@sentinel`
A marker used to signal that you are done with the `@container`. This
should almost always be put right after the last `@delimiter` in the given
`@container`.
- `@_<capture_name>`
Delimiters starting with `_` (underscore) are ignored for highlighting
purposes, but you can use them for treesitter predicates like
`#eq?`, `#any-eq?`, etc. (These are very rarely needed.)

`@container` and `@sentinel` are mandatory, and `@delimiter` will always be
`@container` is mandatory, and at least one `@delimiter` will always be
present as well since `@delimiter` is what is highlighted. The captures
starting with underscore will be rarely used, since you only need them for
predicates in a few special cases.
Expand Down Expand Up @@ -632,7 +628,7 @@ the `<br/>` tag a delimiter. The corresponding query is as follows:
(start_tag) @delimiter
(element
(self_closing_tag) @delimiter)? ; Optional!
(end_tag) @delimiter @sentinel) @container
(end_tag) @delimiter) @container
<
Highlighting the entire tag might be too vibrant though. What if we want to
highlight only the opening and closing angle brackets? The query gets
Expand All @@ -647,10 +643,8 @@ tree.
["<" "/>"] @delimiter))? ;Optional!
(end_tag
"</" @delimiter
">" @delimiter @sentinel))) @container
">" @delimiter))) @container
<
Note that we don't want to put the `@sentinel` on the second to last `@delimiter`
`"</"`, we need to be careful to put it on the last `@delimiter`.

You might now see why we need the `@container` capture group: there is no way
to know in general how deeply the delimiter is nested. Even for one language
Expand All @@ -672,7 +666,7 @@ pleasant middle ground between the two above extremes.
(end_tag
"</" @delimiter
(tag_name) @delimiter
">" @delimiter @sentinel)) @container
">" @delimiter)) @container
<
Here both opening and closing tag have three delimiters each.

Expand All @@ -683,7 +677,7 @@ In HTML the terminating slash in a self-closing tag is optional. Instead of
(start_tag
"<" @delimiter
(tag_name) @delimiter @_tag_name
">" @delimiter @sentinel)) @container
">" @delimiter)) @container
<
However, this query also matches the opening tag of regular tags like `<div>`.
This is where the `@_tag_name` capture comes in. The set of self-closing tags
Expand All @@ -694,7 +688,7 @@ will not match this particular pattern.
(start_tag
"<" @delimiter
(tag_name) @delimiter @_tag_name
">" @delimiter @sentinel)
">" @delimiter)
;; List abridged for brevity
(#any-of? @_tag_name "br" "hr" "input")) @container
<
Expand Down

0 comments on commit a026d4a

Please sign in to comment.