Description
https://github.com/sheerun/vim-polyglot/blob/master/ftdetect/polyglot.vim#L2609
Does this bug happen when you install plugin without vim-polyglot?
No
Describe the bug:
vim-polyglot autoindent only checks the first 32 lines of the file when guessing. In php files with a large number of include statements, there is typically no indentation information available in the first 32 lines. This means that the autoindent plugin will fail to produce the correct results for php files based solely on the number of includes in the file. For example, a file with a small number of includes ends up with shiftwidth=4
, while another file ends up with shiftwidth=2
even though they are in the same project. I think the guess should traverse the entire file until it finds the first line with a leading space, instead of terminating early after only 32 lines. The number of lines to traverse when guessing could be configurable, if performance is a concern, but it should be quite fast to find the first line containing line[0] == " "
.
To Reproduce:
Create any two php files, one of which has at least 32 lines of non-indented top-level statements.