mirror of
https://github.com/lloeki/vimfiles.git
synced 2025-12-06 05:24:39 +01:00
Fix shellcheck shell detection
This commit is contained in:
parent
bffebe63fc
commit
4b8102ebbe
1 changed files with 27 additions and 0 deletions
27
vimrc
27
vimrc
|
|
@ -194,6 +194,32 @@ augroup resCur
|
||||||
endif
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
function! ShellcheckDetect(buffer)
|
||||||
|
for l:line_num in [1, 2, 3]
|
||||||
|
let l:line = get(getbufline(a:buffer, l:line_num), 0, '')
|
||||||
|
|
||||||
|
if l:line[:11] is# '# shellcheck'
|
||||||
|
let l:command = l:line
|
||||||
|
for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh']
|
||||||
|
if l:command =~# l:possible_shell . '\s*$'
|
||||||
|
return l:possible_shell
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ShellcheckSet(buffer)
|
||||||
|
let l:shell = ShellcheckDetect(a:buffer)
|
||||||
|
if l:shell == 'bash'
|
||||||
|
call setbufvar(a:buffer, 'is_bash', 1)
|
||||||
|
else
|
||||||
|
call setbufvar(a:buffer, 'is_bash', 0)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Filetype/language specific settings
|
" Filetype/language specific settings
|
||||||
augroup vimrc
|
augroup vimrc
|
||||||
autocmd! * " clear for reload
|
autocmd! * " clear for reload
|
||||||
|
|
@ -205,6 +231,7 @@ augroup vimrc
|
||||||
autocmd BufRead,BufNewFile *.skim setf slim
|
autocmd BufRead,BufNewFile *.skim setf slim
|
||||||
autocmd BufRead,BufNewFile *.opal setf ruby
|
autocmd BufRead,BufNewFile *.opal setf ruby
|
||||||
autocmd FileType go setl nolist
|
autocmd FileType go setl nolist
|
||||||
|
autocmd FileType sh call ShellcheckSet(bufnr("%"))
|
||||||
autocmd! BufNewFile,BufRead crontab.* setl nobackup | setl nowritebackup " Fix for crontab -e
|
autocmd! BufNewFile,BufRead crontab.* setl nobackup | setl nowritebackup " Fix for crontab -e
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue