jdtsmith / indent-bars

Fast, configurable indentation guide-bars for Emacs
GNU General Public License v3.0
272 stars 7 forks source link

Is there a way to skip certain indent bars on nested structures like arrays/dicts to function parameters? #18

Closed Dima-369 closed 10 months ago

Dima-369 commented 10 months ago

First of all, thank you for this amazing package with the treesitter integration. This brings Emacs closer to what I am used to in PyCharm 🙂

I found a difference and I wondered if any kind of configuration so far can adjust this behavior:

It's best demonstrated with an example. Here is how PyCharm does its indent bars with a array/dict to a function call where it skips indent bars:

CleanShot 2023-09-10 at 20 48 47

It looks like this with indent-bars-mode enabled in Emacs:

CleanShot 2023-09-10 at 21 45 03

Here is the text:

if True:
    if True:
        foo = foo(a1='1',
                  a2=[{
                      "a": "b"
                  }],
                  looooooooooooooooooooooooooooooooooong=False)
jdtsmith commented 10 months ago

Thanks for this example; it revealed a slight misunderstanding I had in the treesit query interface I'm using. Check the latest for a fix. That said, right now I only style one more than the topmost matching node's beginning indent. E.g. the foo = line in this case. So it should look like:

image

I don't have the capability to skip bars and then draw more. Usually arguments get wrapped to line up with the opening paren, so it doesn't make as much sense to align to their start anyway.

Dima-369 commented 10 months ago

Check the latest for a fix.

Works as shown in your screenshot!

I don't have the capability to skip bars and then draw more.

I suppose one could do it by using the same stipple color as the default background color? But maybe that's not reliable.

Usually arguments get wrapped to line up with the opening paren, so it doesn't make as much sense to align to their start anyway.

Visually, it's still a very cool feature when the structures start to nest, but definitely not a deal-breaker and nothing major 😉

CleanShot 2023-09-11 at 07 52 48

jdtsmith commented 10 months ago

I don't mean visually, that wouldn't be hard. It's how to calculate which bars to show, and where. I could certainly find the innermost wrapping entity (list, dict, argument_list, etc.). I guess I could look at the full set of wrapping entities of interest (if any), calculate each of their starting line indent levels, and include only those bars. But this isn't even on a fixed spacing, i.e. depends on the length of the function name. Not sure this one is worth it.