Compare commits

...

6 Commits

Author SHA1 Message Date
Adam Stankiewicz
19a69cf77d Remove debugging code... 2020-09-09 19:22:27 +02:00
Adam Stankiewicz
4f7a4036eb Finally fix issues with tab detection, #541 2020-09-09 19:08:17 +02:00
Adam Stankiewicz
0ff5d451b0 Fix b:sleuth_culprit for tabs 2020-09-09 18:31:30 +02:00
Adam Stankiewicz
49840b1893 Show full path in b:sleuth_culprit 2020-09-09 18:28:28 +02:00
Adam Stankiewicz
2dc954d6fa Last fixes to b:sleuth_culprit 2020-09-09 18:07:03 +02:00
Adam Stankiewicz
2369cd5d22 Make b:sleuth_culprit more readable 2020-09-09 18:02:38 +02:00

View File

@@ -1775,7 +1775,7 @@ endif
" end filetypes " end filetypes
au BufNewFile,BufRead,StdinReadPost * au BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat \ if !did_filetype() && expand("<afile>") !~ g:ft_ignore_pat
\ | call polyglot#Heuristics() | endif \ | call polyglot#Heuristics() | endif
@@ -1799,8 +1799,11 @@ if !has_key(s:disabled_packages, 'autoindent')
let heredoc = '' let heredoc = ''
let minindent = 10 let minindent = 10
let spaces_minus_tabs = 0 let spaces_minus_tabs = 0
let i = 0
for line in a:lines for line in a:lines
let i += 1
if !len(line) || line =~# '^\W*$' if !len(line) || line =~# '^\W*$'
continue continue
endif endif
@@ -1869,12 +1872,13 @@ if !has_key(s:disabled_packages, 'autoindent')
if line[0] == "\t" if line[0] == "\t"
setlocal noexpandtab setlocal noexpandtab
let &shiftwidth=&tabstop
let b:sleuth_culprit .= ':' . i
return 1 return 1
elseif line[0] == " " elseif line[0] == " "
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
@@ -1882,10 +1886,10 @@ if !has_key(s:disabled_packages, 'autoindent')
if minindent < 10 if minindent < 10
setlocal expandtab setlocal expandtab
let &shiftwidth=minindent let &shiftwidth=minindent
let b:sleuth_culprit .= ':' . i
return 1 return 1
endif endif
unlet b:sleuth_culprit
return 0 return 0
endfunction endfunction
@@ -1894,7 +1898,7 @@ if !has_key(s:disabled_packages, 'autoindent')
return return
endif endif
let b:sleuth_culprit = expand("<amatch>") let b:sleuth_culprit = expand("<afile>:p")
if s:guess(getline(1, 32)) if s:guess(getline(1, 32))
return return
endif endif
@@ -1908,13 +1912,15 @@ if !has_key(s:disabled_packages, 'autoindent')
while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0 while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0
" Ignore files from homedir and root " Ignore files from homedir and root
if dir == expand('~') || dir == '/' if dir == expand('~') || dir == '/'
unlet b:sleuth_culprit
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 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 let level = 0
continue
endif endif
if neighbor !=# expand('%:p') && filereadable(neighbor) if neighbor !=# expand('%:p') && filereadable(neighbor)
if s:guess(readfile(neighbor, '', 32)) if s:guess(readfile(neighbor, '', 32))
@@ -1926,6 +1932,8 @@ if !has_key(s:disabled_packages, 'autoindent')
let dir = fnamemodify(dir, ':h') let dir = fnamemodify(dir, ':h')
let level -= 1 let level -= 1
endwhile endwhile
unlet b:sleuth_culprit
endfunction endfunction
setglobal smarttab setglobal smarttab