aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-29 23:53:19 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-29 23:53:19 +1200
commit96db918abcd035c9cc8db8ce1d25d404d1f848bf (patch)
tree3d0060a8b1b1fec38f7f6c736ef791efa9ce1cdc
parentCommit first pass at indent heuristic (diff)
downloaddotfiles-96db918abcd035c9cc8db8ce1d25d404d1f848bf.tar.gz
dotfiles-96db918abcd035c9cc8db8ce1d25d404d1f848bf.zip
Commit a much simpler approach to indent guessing
-rw-r--r--vim/plugin/detect_indent.vim24
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