1
0
mirror of https://github.com/amix/vimrc synced 2025-07-21 11:54:59 +08:00
This commit is contained in:
huangqundl
2017-03-17 23:12:53 +08:00
parent 47b213d974
commit cba39b7326
855 changed files with 59981 additions and 35298 deletions

View File

@ -9,7 +9,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_sh_bashate_checker")
if exists('g:loaded_syntastic_sh_bashate_checker')
finish
endif
let g:loaded_syntastic_sh_bashate_checker = 1
@ -22,7 +22,7 @@ function! SyntaxCheckers_sh_bashate_GetLocList() dict
let errorformat =
\ '%EE%n: %m,' .
\ '%Z - %f: L%l,' .
\ '%Z - %f%\s%\+: L%l,' .
\ '%-G%.%#'
let loclist = SyntasticMake({
@ -45,4 +45,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -6,7 +6,7 @@
" as part of the devscripts package.
"============================================================================
if exists("g:loaded_syntastic_sh_checkbashisms_checker")
if exists('g:loaded_syntastic_sh_checkbashisms_checker')
finish
endif
let g:loaded_syntastic_sh_checkbashisms_checker = 1
@ -39,4 +39,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -10,7 +10,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_sh_sh_checker")
if exists('g:loaded_syntastic_sh_sh_checker')
finish
endif
let g:loaded_syntastic_sh_sh_checker = 1
@ -18,22 +18,24 @@ let g:loaded_syntastic_sh_sh_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_sh_sh_IsAvailable() dict
call self.log('shell =', s:GetShell())
return s:IsShellValid()
endfunction
function! SyntaxCheckers_sh_sh_IsAvailable() dict " {{{1
let buf = bufnr('')
call self.log('shell =', s:GetShell(buf))
return s:IsShellValid(buf)
endfunction " }}}1
function! SyntaxCheckers_sh_sh_GetLocList() dict
if s:GetShell() ==# 'zsh'
function! SyntaxCheckers_sh_sh_GetLocList() dict " {{{1
let buf = bufnr('')
if s:GetShell(buf) ==# 'zsh'
return s:ForwardToZshChecker()
endif
if !s:IsShellValid()
if !s:IsShellValid(buf)
return []
endif
let makeprg = self.makeprgBuild({
\ 'exe': s:GetShell(),
\ 'exe': s:GetShell(buf),
\ 'args_after': '-n' })
let errorformat = '%f: line %l: %m'
@ -41,35 +43,37 @@ function! SyntaxCheckers_sh_sh_GetLocList() dict
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat })
endfunction
endfunction " }}}1
function! s:GetShell()
if !exists('b:shell') || b:shell == ''
let b:shell = ''
let shebang = syntastic#util#parseShebang()['exe']
if shebang != ''
" Utilities {{{1
function! s:GetShell(buf) " {{{2
let shell = syntastic#util#getbufvar(a:buf, 'shell')
if shell ==# ''
let shebang = syntastic#util#parseShebang(a:buf)['exe']
if shebang !=# ''
if shebang[-strlen('bash'):-1] ==# 'bash'
let b:shell = 'bash'
let shell = 'bash'
elseif shebang[-strlen('zsh'):-1] ==# 'zsh'
let b:shell = 'zsh'
let shell = 'zsh'
elseif shebang[-strlen('sh'):-1] ==# 'sh'
let b:shell = 'sh'
let shell = 'sh'
endif
endif
" try to use env variable in case no shebang could be found
if b:shell == ''
let b:shell = fnamemodify($SHELL, ':t')
if shell ==# ''
let shell = fnamemodify($SHELL, ':t')
endif
endif
return b:shell
endfunction
return shell
endfunction " }}}2
function! s:IsShellValid()
let shell = s:GetShell()
return shell != '' && executable(shell)
endfunction
function! s:IsShellValid(buf) " {{{2
let shell = s:GetShell(a:buf)
return shell !=# '' && executable(shell)
endfunction " }}}2
function! s:ForwardToZshChecker()
function! s:ForwardToZshChecker() " {{{2
let registry = g:SyntasticRegistry.Instance()
let zsh_checkers = registry.getCheckersAvailable('zsh', ['zsh'])
if !empty(zsh_checkers)
@ -77,7 +81,9 @@ function! s:ForwardToZshChecker()
else
return []
endif
endfunction
endfunction " }}}2
" }}}1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'sh',
@ -86,4 +92,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -3,7 +3,7 @@
"Description: Shell script syntax/style checking plugin for syntastic.vim
"============================================================================
if exists("g:loaded_syntastic_sh_shellcheck_checker")
if exists('g:loaded_syntastic_sh_shellcheck_checker')
finish
endif
let g:loaded_syntastic_sh_shellcheck_checker = 1
@ -11,8 +11,11 @@ let g:loaded_syntastic_sh_shellcheck_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_sh_shellcheck_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_after': '-f gcc' })
function! SyntaxCheckers_sh_shellcheck_GetLocList() dict " {{{1
let buf = bufnr('')
let makeprg = self.makeprgBuild({
\ 'args': s:GetShell(buf),
\ 'args_after': '-f gcc' })
let errorformat =
\ '%f:%l:%c: %trror: %m,' .
@ -32,7 +35,27 @@ function! SyntaxCheckers_sh_shellcheck_GetLocList() dict
endfor
return loclist
endfunction
endfunction " }}}1
" Utilities {{{1
function! s:GetShell(buf) " {{{2
let sh = ''
if syntastic#util#parseShebang(a:buf)['exe'] ==# ''
if syntastic#util#bufRawVar(a:buf, 'is_kornshell', 0) || syntastic#util#bufRawVar(a:buf, 'is_posix', 0)
let sh = 'ksh'
elseif syntastic#util#bufRawVar(a:buf, 'is_bash', 0)
let sh = 'bash'
elseif syntastic#util#bufRawVar(a:buf, 'is_sh', 0)
let sh = 'sh'
endif
endif
return sh !=# '' ? '-s ' . sh : ''
endfunction " }}}2
" }}}1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'sh',
@ -41,4 +64,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker: