From cf015d2e86e7dd7257ec93d584927205a487c3ab Mon Sep 17 00:00:00 2001 From: wickles Date: Sun, 2 Jul 2023 17:49:57 -0700 Subject: [PATCH] More heuristic tabstop If the file is mostly space indents, set tabstop to shiftwidth. --- plugin/sleuth.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/sleuth.vim b/plugin/sleuth.vim index 628adbb..9584cc6 100644 --- a/plugin/sleuth.vim +++ b/plugin/sleuth.vim @@ -133,11 +133,11 @@ function! s:Guess(source, detected, lines) abort if heuristics.soft let options.expandtab = 1 endif - if heuristics.hard || has_key(a:detected.options, 'tabstop') || - \ stridx(join(a:lines, "\n"), "\t") >= 0 + if has_key(a:detected.options, 'tabstop') let options.tabstop = tabstop - elseif !&g:shiftwidth && has_key(options, 'shiftwidth') && - \ !has_key(a:detected.options, 'shiftwidth') + elseif heuristics.spaces > heuristics.hard || + \ (!&g:shiftwidth && has_key(options, 'shiftwidth') && + \ !has_key(a:detected.options, 'shiftwidth')) let options.tabstop = options.shiftwidth let options.shiftwidth = 0 endif