Make it easier to debug indentation issues, #542

This commit is contained in:
Adam Stankiewicz
2020-09-09 17:39:27 +02:00
parent 2fe310256e
commit a4cc3f64f9

View File

@@ -1780,6 +1780,7 @@ au BufNewFile,BufRead,StdinReadPost *
if !has_key(s:disabled_packages, 'autoindent') if !has_key(s:disabled_packages, 'autoindent')
" Code below re-implements sleuth for vim-polyglot " Code below re-implements sleuth for vim-polyglot
let g:loaded_sleuth = 1 let g:loaded_sleuth = 1
let g:loaded_foobar = 1
" Makes shiftwidth to be synchronized with tabstop by default " Makes shiftwidth to be synchronized with tabstop by default
if &shiftwidth == &tabstop if &shiftwidth == &tabstop
@@ -1871,6 +1872,7 @@ if !has_key(s:disabled_packages, 'autoindent')
let indent = len(matchstr(line, '^ *')) let indent = len(matchstr(line, '^ *'))
if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent
let minindent = indent let minindent = indent
let b:sleuth_culprit .= ":" . line
endif endif
endif endif
endfor endfor
@@ -1881,6 +1883,7 @@ if !has_key(s:disabled_packages, 'autoindent')
return 1 return 1
endif endif
unlet b:sleuth_culprit
return 0 return 0
endfunction endfunction
@@ -1889,6 +1892,7 @@ if !has_key(s:disabled_packages, 'autoindent')
return return
endif endif
let b:sleuth_culprit = expand("<amatch>")
if s:guess(getline(1, 32)) if s:guess(getline(1, 32))
return return
endif endif
@@ -1905,6 +1909,7 @@ if !has_key(s:disabled_packages, 'autoindent')
return return
endif endif
for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level] for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level]
let b:sleuth_culprit = neighbor
" Do not consider directories above .git, .svn or .hg " Do not consider directories above .git, .svn or .hg
if fnamemodify(neighbor, ":h:t")[0] == "." if fnamemodify(neighbor, ":h:t")[0] == "."
return return