Compare commits

...

3 Commits

Author SHA1 Message Date
Adam Stankiewicz
b0124dc880 Ignore files from homedir and root for indent
https://github.com/tpope/vim-sleuth/pull/57
2020-09-04 19:45:47 +02:00
Adam Stankiewicz
99166bd51f Do not set indent on by default
https://github.com/tpope/vim-sleuth/issues/21
2020-09-04 19:21:08 +02:00
Adam Stankiewicz
48b4f233c5 Fix detecting indentation in some CSS
This is done by ignoring lines that don't have any
alphanumeric characters, e.g. following would be detected
as 4-spaces indentation instead of 2-spaces

.android {
    height: 404px; width: 334px;
    margin: 100px auto;
  }

https://github.com/tpope/vim-sleuth/issues/22
2020-09-04 19:02:39 +02:00

View File

@@ -36,7 +36,7 @@ function! s:guess(lines) abort
let spaces_minus_tabs = 0
for line in a:lines
if !len(line) || line =~# '^\s*$'
if !len(line) || line =~# '^\W*$'
continue
endif
@@ -138,6 +138,10 @@ function! s:detect_indent() abort
let dir = expand('%:p:h')
let level = 3
while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0
" Ignore files from homedir and root
if dir == expand('~') || dir == '/'
return
endif
for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level]
" Do not consider directories above .git, .svn or .hg
if fnamemodify(neighbor, ":h:t")[0] == "."
@@ -157,10 +161,6 @@ endfunction
setglobal smarttab
if !exists('g:did_indent_on')
filetype indent on
endif
augroup polyglot
autocmd!
autocmd FileType * call s:detect_indent()