aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-30 01:31:04 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-30 01:31:04 +1200
commit292969d2a27e447d55e30cf64bb85def6687032c (patch)
treee4d1e9fef22ba14b14747d5f1995a5c85466b661
parentArrange and comment code for new plugin (diff)
downloaddotfiles-292969d2a27e447d55e30cf64bb85def6687032c.tar.gz
dotfiles-292969d2a27e447d55e30cf64bb85def6687032c.zip
Make properties of detect_indent.vim configgable
-rw-r--r--vim/autoload/detect_indent.vim12
1 files changed, 7 insertions, 5 deletions
diff --git a/vim/autoload/detect_indent.vim b/vim/autoload/detect_indent.vim
index b4de2159..28d379c3 100644
--- a/vim/autoload/detect_indent.vim
+++ b/vim/autoload/detect_indent.vim
@@ -17,8 +17,9 @@ function detect_indent#() abort
\ 'total': 0,
\}
- " Figure out how many lines we'll check; cap this to 1,024
- let total = max([line('$'), 1024])
+ " Figure out how many lines we'll check; cap this to 1,024, or whatever the
+ " user configured
+ let total = max([line('$'), get(g:, 'detect_indent_limit', 1024)])
" Iterate through the lines
for line in getline(1, total)
@@ -73,15 +74,16 @@ function detect_indent#() abort
" Iterate through the keys of the histogram from smallest to largest.
" We'll accept as our 'shiftwidth' the smallest indent level that
- " constitutes more than 5% of the total lines. This is just an heuristic,
- " but it seems to work pretty well.
+ " constitutes more than 5% of the total lines, configurable by the user.
+ " This is just an heuristic, but it seems to work pretty well.
"
let shiftwidth = 0
let indents = keys(spaces['hist'])
call map(indents, 'str2nr(v:val)') " Coerce the string keys to numeric
call sort(indents, 's:CompareNumeric') " Force numeric sort
for shiftwidth in indents
- if spaces['hist'][shiftwidth] * 100 / spaces['total'] >= 5
+ if spaces['hist'][shiftwidth] * 100 / spaces['total']
+ \ >= get(g:, 'detect_indent_confidence', 5)
break
endif
endfor