folke / twilight.nvim

🌅 Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.
Apache License 2.0
1.24k stars 21 forks source link

[Feature request] Highlight current block entirely #14

Closed hood closed 1 month ago

hood commented 3 years ago

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.

folke commented 3 years ago

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?

hood commented 3 years ago

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

folke commented 3 years ago

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.

hood commented 3 years ago

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

screenshot

folke commented 3 years ago

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

hood commented 3 years ago

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

vigoux commented 2 years ago

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 ?

folke commented 2 years ago

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

vigoux commented 2 years ago

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)!

iCraft85 commented 1 year ago

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
github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 7 days with no activity.