diff options
-rw-r--r-- | vim/plugin/detect_indent.vim | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/vim/plugin/detect_indent.vim b/vim/plugin/detect_indent.vim index cbd2cf91..f8dd8966 100644 --- a/vim/plugin/detect_indent.vim +++ b/vim/plugin/detect_indent.vim @@ -26,29 +26,15 @@ function Count() abort let &l:shiftwidth = &tabstop setlocal expandtab? elseif !&expandtab && spaces['total'] > tabs * 5 - let set = [] - for indent in keys(spaces['hist']) - if spaces['hist'][indent] * 100 / spaces['total'] >= 5 - call add(set, indent) - endif - endfor - let shiftwidth = 1 - let continue = 1 - for divisor in range(2, max(set)) - for indent in set - if indent % divisor != 0 - let continue = 0 - break - endif - endfor - if !continue + let shiftwidth = 0 + for shiftwidth in sort(keys(spaces['hist'])) + if spaces['hist'][shiftwidth] * 100 / spaces['total'] >= 5 break endif - let gcd = div endfor setlocal expandtab - let &l:shiftwidth = gcd - let &l:softtabstop = gcd + let &l:shiftwidth = shiftwidth + let &l:softtabstop = shiftwidth setlocal expandtab? shiftwidth? endif |