folke / twilight.nvim

🌅 Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature request] Highlight current block entirely

hood opened this issue · comments

As the title says, it'd be cool to be able to get this plugin to ighlight the whole parent block entirely, instead of highliting the current code block from its start to the current line.

Would be great if you could post a screenshot of the behavior you would like to see, since it's not entirely clear what you're asking :)

I saw you also posted #13 Is that a duplicate of this one?

Yep, #13 is a duplicate of this, I posted twice because I had a submission error thrown at me the first time for some reason.

Here a few screenshots showing the behaviour I'd like to see improved:
https://ibb.co/y4JkfB4 <- here only a relative block is highlighted, instead of the entire method I'm in
https://ibb.co/P6qRmnd <- here other methods are being highlighted too, instead of only the one I'm in

First of all. This is a buffer that has treesitter enabled right?

Of so, then use the treesitter playground plugin to determine what the scope is of the function (it's not function or method, since we already include those)

Once you know the scope, add it in the expand section of the config.

Would also be great to let me know that scope, since it might be useful to add to the default expand scopes.

This is what I'm seeing using treesitter's playground plugin.

screenshot

You'll probably get what you want by adding method_definition to the expand section of the config. Does that work?

@folke Thanks a lot, man. That worked like a charm!

Reviving this issue: do you think you could use the scope in tree-sitter locals in order to make the dimming ?
I think that this would help a lot in the clarity, and make the plugin more predictable in some cases ?

@vigoux I totally missed the addition of the locals queries! Definitely something I can use to improve Twilight.

It's actually not a really known feature of tree-sitter, but I think you can leverage it 😉
Tell me if I can help in any way, I just started using the plugin, and I really like it so far, great work (again)!

Hi! I wanted to know if someone could help me with how I can highlight everything inside of the dependencies block thats there in the screenshot?

Screenshot 2023-01-17 at 9 46 29 PM

Looking at the TS Playground in the image, indicates that the value I should use is table_constructor

Screenshot 2023-01-17 at 9 48 42 PM

I tried this but this lead to everything the in outer layer which is also a table_constructor getting highlighted.

Screenshot 2023-01-17 at 9 52 41 PM

I need someway to get it to chose to highlight the inner most block present.

Also on a similar to this, how can I get Twilight to only highlight the lsp.ensure_installed and it's contents

Screenshot 2023-01-17 at 9 54 07 PM