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

Add config: g:polyglot_autoindent_guess_lines #594

Closed
wants to merge 1 commit into from
Closed

Add config: g:polyglot_autoindent_guess_lines #594

wants to merge 1 commit into from

Conversation

gou4shi1
Copy link

@gou4shi1 gou4shi1 commented Oct 19, 2020

Only guess in the first 32 lines give me a wrong shiftwidth.

@sheerun
Copy link
Owner

sheerun commented Oct 19, 2020

I'd rather avoid adding options. I improved heuristics algorithm and increased default number of lines to 64, could you check?

@gou4shi1
Copy link
Author

Sorry, it get worser...
I'm editing a cpp file with shiftwidth=2 and using clang-format to auto format it.
The new heuristics algorithm give me 4 while the old algorithm give me 2 if I increase default number of lines to 64...

@sheerun
Copy link
Owner

sheerun commented Oct 19, 2020

Could you show example file that causes this issue?

@gou4shi1
Copy link
Author

@gou4shi1
Copy link
Author

gou4shi1 commented Oct 19, 2020

For cpp, I think we should use the min indent as shiftwidth (as the old algorithm), since the auto formatter will break line (longer than 80) with many space...

@sheerun
Copy link
Owner

sheerun commented Oct 19, 2020

I want to avoid creating filetype-specific detectors. I think it's just a matter of time until we find "correct" algorithm that works for almost all languages. It's matter designing one that can do the same as human does. i.e. Even if you did't know c++, why when you look at first 32 lines of this file you think correct indent is 2? In this case the answer is that most of indented code is at "difference" of 2, when counting each line. I've changed the algorithm to do just that. Is it ok now for everything?

@gou4shi1
Copy link
Author

It works! Thanks a lot!

@gou4shi1 gou4shi1 closed this Oct 20, 2020
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.

2 participants