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

Match first node for expand options. #31

Closed NiamhFerns closed 1 month ago

NiamhFerns commented 1 year ago

Current Behaviour: Currently, when you have nodes to expand to in your twilight config, twilight will expand to whatever the outer most one is. That is, say I have my expand to expand to conditionals, loops, methods, and classes, then I have some code that looks like this.

class Foo:
    def bar():
        if condition:
            var = expression
            for i in collection:
                # do things

Say I have my cursor on line 4, it will highlight every single line of code because it matches to the outermost node, that being the class.

Desired Behaviour: I'd like it to match to innermost scope/node and no further. That is, if we have the above example, I'd want it to highlight only the conditional. If I had my cursor on line 6 I'd want it to highlight only the for loop.

Ideally, it would do this from within the block but not on the block declaration itself. This means that if I had my cursor on line 3, it's on the conditional line but it considers it considers the closest inner node as the one just above, that being the method. It also prevents annoying cases where you have a one-liner if statement or things like that.

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.