HiPhish / rainbow-delimiters.nvim

Rainbow delimiters for Neovim with Tree-sitter
https://gitlab.com/HiPhish/rainbow-delimiters.nvim
Apache License 2.0
533 stars 39 forks source link

Add comment on `html-tag-names` queries #57

Closed Danielkonge closed 10 months ago

Danielkonge commented 10 months ago

I saw a request to be able to keep the old style html highlighting on reddit, so I thought I would add it. Please let me know if you have a better name for it.

HiPhish commented 10 months ago

Do we really want such a query included by default? That's a very niche use-case and I don't think anyone else will want it. Plus, if we include it I would like the same for React as well.

Danielkonge commented 10 months ago

Do we really want such a query included by default? That's a very niche use-case and I don't think anyone else will want it. Plus, if we include it I would like the same for React as well.

I guess it will add extra stuff to maintain that might not be used by a lot of people. Do you think it would make sense if I instead add a brief comment about how to make this in the html queries file? (I.e. in html/rainbow-delimiters.scm.)

HiPhish commented 10 months ago

I guess it will add extra stuff to maintain that might not be used by a lot of people.

Right. Tree-sitter queries don't have any mechanism for abstraction, so there will be a lot of copy-pasting that needs to be kept in sync manually. If certain patterns are commonly used it makes sense to do it, but such a niche case is just an extra maintenance burden. This is precisely the reason why I wanted to offer an escape hatch to people from day one. Whatever weird or silly query or strategy you have, you can add it yourself to your own config.

Do you think it would make sense if I instead add a brief comment about how to make this in the html queries file?

That sounds like a good idea to me.

Danielkonge commented 10 months ago

I have changed the pull request, so now it only adds a brief comment about how to make something like rainbow-tag-names queries.

DeadlySquad13 commented 10 months ago

Thanks for attention to my comment! Don't really understand why it's niche though, have always thought that it's the best way to minimize clutter on screen but well to each his own :D...

HiPhish commented 10 months ago

Merged, thank you.

Don't really understand why it's niche though, have always thought that it's the best way to minimize clutter on screen

I imagine (and I am going purely by instinct) that most people don't have special highlighting to subdue the angle brackets. Now that I think about it, maybe you might want to completely hide the angle brackets or replace them with some other character. You can do that using Tree-sitter without any plugin. Create the query after/queries/html/highlights.scm (name does matter) with the following contents:

;; extends

((start_tag ( "<" @tag.delimiter.html (#set! conceal  ""))))
((start_tag ( ">" @tag.delimiter.html (#set! conceal  ""))))
((end_tag   ("</" @tag.delimiter.html (#set! conceal "/"))))
((end_tag   ( ">" @tag.delimiter.html (#set! conceal  ""))))

This will hide all angle brackets, except for </ which will be replaced with just /. Then you don't need a special query for rainbow delimiters because the delimiters will be hidden anyway. It's not what I would do, but hey, it's your editor, you can do whatever you want.