From 96db918abcd035c9cc8db8ce1d25d404d1f848bf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 May 2020 23:53:19 +1200 Subject: Commit a much simpler approach to indent guessing --- vim/plugin/detect_indent.vim | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'vim') 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 -- cgit v1.2.3