mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-09 03:53:52 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0124dc880 | ||
|
|
99166bd51f | ||
|
|
48b4f233c5 | ||
|
|
556ba05cee |
@@ -31,11 +31,12 @@ function! s:guess(lines) abort
|
|||||||
let triplequote = 0
|
let triplequote = 0
|
||||||
let backtick = 0
|
let backtick = 0
|
||||||
let xmlcomment = 0
|
let xmlcomment = 0
|
||||||
|
let heredoc = ''
|
||||||
let minindent = 10
|
let minindent = 10
|
||||||
let spaces_minus_tabs = 0
|
let spaces_minus_tabs = 0
|
||||||
|
|
||||||
for line in a:lines
|
for line in a:lines
|
||||||
if !len(line) || line =~# '^\s*$'
|
if !len(line) || line =~# '^\W*$'
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -87,6 +88,18 @@ function! s:guess(lines) abort
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" This is correct order because both "<<EOF" and "EOF" matches end
|
||||||
|
if heredoc != ''
|
||||||
|
if line =~# heredoc
|
||||||
|
let heredoc = ''
|
||||||
|
endif
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
let herematch = matchlist(line, '\C<<\W*\([A-Z]\+\)\s*$')
|
||||||
|
if len(herematch) > 0
|
||||||
|
let heredoc = herematch[1] . '$'
|
||||||
|
endif
|
||||||
|
|
||||||
let spaces_minus_tabs += line[0] == "\t" ? 1 : -1
|
let spaces_minus_tabs += line[0] == "\t" ? 1 : -1
|
||||||
|
|
||||||
if line[0] == "\t"
|
if line[0] == "\t"
|
||||||
@@ -125,6 +138,10 @@ function! s:detect_indent() abort
|
|||||||
let dir = expand('%:p:h')
|
let dir = expand('%:p:h')
|
||||||
let level = 3
|
let level = 3
|
||||||
while isdirectory(dir) && dir !=# fnamemodify(dir, ':h') && level > 0
|
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]
|
for neighbor in glob(dir . '/' . pattern, 0, 1)[0:level]
|
||||||
" 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] == "."
|
||||||
@@ -144,10 +161,6 @@ endfunction
|
|||||||
|
|
||||||
setglobal smarttab
|
setglobal smarttab
|
||||||
|
|
||||||
if !exists('g:did_indent_on')
|
|
||||||
filetype indent on
|
|
||||||
endif
|
|
||||||
|
|
||||||
augroup polyglot
|
augroup polyglot
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType * call s:detect_indent()
|
autocmd FileType * call s:detect_indent()
|
||||||
|
|||||||
Reference in New Issue
Block a user