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

Fast current_indent (resolves #649) #726

Closed
wants to merge 16 commits into from

Conversation

Danielkonge
Copy link
Contributor

Here is a cleaned up version of my implementation of current_indent that doesn't contain other features.

This pull request will resolve #649.

Copy link
Owner

@lukas-reineke lukas-reineke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current indent should also support show_start and show_end.
And you need to add priority that decides if scope or current indent is displayed if they are in the same place.

lua/ibl/init.lua Outdated Show resolved Hide resolved
@lukas-reineke
Copy link
Owner

I get this behavior with tabs. The second if block should not be highlighted

2023-10-13_17-42

@Danielkonge
Copy link
Contributor Author

I get this behavior with tabs. The second if block should not be highlighted

2023-10-13_17-42

This should be fixed now. (Please let me know if it not.) I used indent_state.stack to decide what indents were drawn, but I can see it doesn't work as I would expect in all cases (e.g. with the blank lines in the if statements like in the picture). To overcome this I have constructed a table drawn_indents alongside the whitespace_tbl that keeps track of exactly which indents have been drawn. This also simplifies a workaround with blank lines I used earlier.

@Danielkonge
Copy link
Contributor Author

Danielkonge commented Oct 13, 2023

I have added priority, show_start and show_end now. Note that show_end doesn't really make sense in the same way for the indentation guides as for scope, so the only thing I think makes sense here is to underline the line below the end of the current indent level if you enable it (and there is a line to underline).

@lukas-reineke
Copy link
Owner

I don't quite understand the need for drawn_indents, isn't it just the same information you already have in whitespace_tbl?

@Danielkonge
Copy link
Contributor Author

Danielkonge commented Oct 16, 2023

I don't quite understand the need for drawn_indents, isn't it just the same information you already have in whitespace_tbl?

The information in drawn_indents is already in whitespace_tbl, yes. I just thought it was easier to work with a list of purely the indents, whereas whitespace_tbl includes spaces and other stuff too. If you prefer, I can rewrite it to just use whitespace_tbl directly (you will just need to search backwards through whitespace_tbl for the indents).

drawn_indents just contains the (0-indexed) positions of TAB_START, TAB_START_SINGLE and INDENT in the whitespace_tbl (and it ignores TAB_FILL, TAB_END and SPACE), since these are the ones used for drawing the indentation guides.

@lukas-reineke
Copy link
Owner

👍 yeah that's what I mean. Let's just use whitespace_tbl. You can make a helper function to give you back the indents.
It shouldn't hurt performance, and it's easier to understand when there is only one data source.

@Danielkonge
Copy link
Contributor Author

👍 yeah that's what I mean. Let's just use whitespace_tbl. You can make a helper function to give you back the indents. It shouldn't hurt performance, and it's easier to understand when there is only one data source.

Since I only actually really need the last indent column and the number of indents I have made a helper function to return these given a whitespace table now.

@Danielkonge
Copy link
Contributor Author

Since the other pull request is almost ready, I will close this one.

@wookayin
Copy link

wookayin commented Nov 2, 2023

Continued in #743 (adding a ref here because they were not linked). Thanks @Danielkonge for the great work.

@Danielkonge Danielkonge deleted the current_indent branch December 15, 2023 11:52
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.

Highlight current indent (no color) with a lower priority than scope (with color)
3 participants