From 292969d2a27e447d55e30cf64bb85def6687032c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 30 May 2020 01:31:04 +1200 Subject: Make properties of detect_indent.vim configgable --- vim/autoload/detect_indent.vim | 12 +++++++----- 1 file 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 -- cgit v1.2.3