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

Only show indent guides for current block (resolves #561) #723

Closed

Conversation

Danielkonge
Copy link
Contributor

@Danielkonge Danielkonge commented Oct 10, 2023

This should resolve #561. If you want anything to change I can edit it later today.

One thing to consider is if there should be an option to change the behavior when you are not in any code block. Right now it will not show any indent guides when you are not in a code block, and then only show the blocks indent guides when you are in a code block. I think this could be useful for viewing large files with multiple different blocks, which is why I picked this behavior as the standard.

Also, I am not sure exactly how you would want to write tests for this, but if you point me in the right direction, I can also try to look into that.

@lukas-reineke
Copy link
Owner

I think it makes more sense if this builds on current indent right?

@Danielkonge
Copy link
Contributor Author

You are right, but I thought some people will want to use this without using current_indent. But I guess I can just make it so that you only do the necessary calculation if either current_indent needs it or this needs it. I will make a new pull request with those features both then.

@Danielkonge
Copy link
Contributor Author

Sorry, I will reopen this, but I improved it so it doesn't use scope now. It was not a good idea to use scope since it doesn't capture the right thing, but I do think we want to use treesitter for this. Without treesitter, it can be hard to describe the exact block you are in (this is a different thing than what current_indent does, since it doesn't care where the block starts/ends, it just looks at where the indent guides start/end).

All languages I have tested (and I think this should generally be true for treesitter?) has new code blocks as the child of the root, so going up the tree until you see the root should always work (if my assumption is true).

@Danielkonge Danielkonge reopened this Oct 11, 2023
@lukas-reineke
Copy link
Owner

I don't think treesitter is the right tool for this.
This is basically current indent, but walking up all indent levels until you hit the root.

For current indent, you keep a stack of all indents until you hit the cursor, then display the deepest one differently.
For this feature, you would display all indents in the stack, and nothing else.

@Danielkonge
Copy link
Contributor Author

Ah, I think I misunderstood what you said originally. Keeping a stack similar to current_ident but for current_block like what you described should definitely be possible. I can try to do that later.

I think I will wait until current_indent has been accepted though, so I will know what I can use from that pull request.

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

Successfully merging this pull request may close these issues.

Feature Request: Only show indent lines on my current code "block"
2 participants