Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Better document how to customize which text should be visible #24

Open
Hubro opened this issue Apr 11, 2022 · 2 comments

Comments

@Hubro
Copy link

Hubro commented Apr 11, 2022

I don't understand how Twilight decides which text should be visible, or how to customize it. I use it with Python + Treesitter, and here's an example of how it works:

image

I would like it to always expand to include the nearest parent function definition, or the nearest parent class definition if I'm not currently inside a function definition.

It sounds like, based on this:

expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
"function",
"method",
"table",
"if_statement",
},

That it already should try to include the entire function definition, but it doesn't. It also sounds like based on this:

context = 10, -- amount of lines we will try to show around the current line

That it should show at least 10 lines above/below the current line, but it doesn't do that either. In the screenshot, it only shows 1 line above the current line.

I would really love some more in-depth documentation so I can customize which text is visible.

@silentjay
Copy link

You can install treesitter playground to find the code blocks you want to highlight and add it to the expand list. In your image I assume this means you'd want to add function_definition to expand.

@Hubro
Copy link
Author

Hubro commented May 12, 2022

Hey, that works!

Is there currently any way to specify "expand until the closest parent of one of the following types"?

i.e. expand to either a function definition or class definition, whichever is closer?

So if I'm editing the properties of a class:

class Foo:
    bar: int = 123
    baz: str = "foo"
    # etc.

At this point, I want Twilight to keep the entire class in focus, but if I'm editing a class method, I only want the function definition in focus, not the entire class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants