rktjmp / lush.nvim

Create Neovim themes with real-time feedback, export anywhere.
MIT License
1.4k stars 46 forks source link

Using new Treesitter groups/tags #107

Closed OkanEsen closed 1 year ago

OkanEsen commented 1 year ago

Hi!

Is there a way to comply with the new way of how the Treesitter highlight groups are used in Neovim +0.8? Previously the old group names were prefixed with a TS* prefix but this is deprecated now (https://github.com/nvim-treesitter/nvim-treesitter/pull/3656) and one has to use the tags now (TSError -> @error).

I tried to use these tags as names for my theme but that unfortunately doesn't work. I don't think, this is possible with how the spec is currently defined right?

Example:

-- Old
TSError {Red},

-- New
@error {Red},
-- I intuitively tried these as well but they don't work either.
-- "@error" {Red},
-- ["@error"] {Red},
rktjmp commented 1 year ago

First I've seen of this!

Hm... Will have to think about if it's possible. TSError is basically injected into a scope under that name, but @error isn't a valid lua name so ... Seems we have to support @x.y variants too.

There are a few options or at least work arounds, but they wont work with Lushify:

  1. manually define some hi link @error my_at_error_group in your theme/config
  2. Use the build system (BUILD.md) and manually apply some post-processing to the highlight groups returned, so you could convert the group named ATError to @error.
  3. ... ?
OkanEsen commented 1 year ago

Yeah, no worries and thank you for your reply. It's a little unfortunate, that the prefixes were dropped but that's how it is. :-)

I think I'll go with your first suggestion for now, thank you very much!

clason commented 1 year ago

@ and . are officially supported in highlight group identifiers in Nvim 0.8 (before, they triggered a warning -- not an error -- but still worked).

This was noted in Neovim's pinned "Following HEAD" issue when the change was made back in August. (Users and plugin authors are strongly encouraged to subscribe to this issue, especially when they rely on experimental features like treesitter support.)

rktjmp commented 1 year ago

See https://github.com/rktjmp/lush.nvim/issues/109