]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/syntax_checkers/sh.vim
Update the stuff
[rbdr/dotfiles] / vim / syntax_checkers / sh.vim
CommitLineData
0d23b6e5
BB
1"============================================================================
2"File: sh.vim
3"Description: Syntax checking plugin for syntastic.vim
4"Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
5"License: This program is free software. It comes without any warranty,
6" to the extent permitted by applicable law. You can redistribute
7" it and/or modify it under the terms of the Do What The Fuck You
8" Want To Public License, Version 2, as published by Sam Hocevar.
9" See http://sam.zoy.org/wtfpl/COPYING for more details.
10"
11"============================================================================
12if exists('loaded_sh_syntax_checker')
13 finish
14endif
15let loaded_sh_syntax_checker = 1
16
17function! s:GetShell()
18 if !exists('b:shell') || b:shell == ""
19 let b:shell = ''
20 let shebang = getbufline(bufnr('%'), 1)[0]
21 if len(shebang) > 0
22 if match(shebang, 'bash') >= 0
23 let b:shell = 'bash'
24 elseif match(shebang, 'zsh') >= 0
25 let b:shell = 'zsh'
26 elseif match(shebang, 'sh') >= 0
27 let b:shell = 'sh'
28 endif
29 endif
30 endif
31 return b:shell
32endfunction
33
34function! SyntaxCheckers_sh_GetLocList()
35 if len(s:GetShell()) == 0 || !executable(s:GetShell())
36 return []
37 endif
38 let output = split(system(s:GetShell().' -n '.shellescape(expand('%'))), '\n')
39 if v:shell_error != 0
40 let result = []
41 for err_line in output
42 let line = substitute(err_line, '^[^:]*:\D\{-}\(\d\+\):.*', '\1', '')
43 let msg = substitute(err_line, '^[^:]*:\D\{-}\d\+: \(.*\)', '\1', '')
44 call add(result, {'lnum' : line,
45 \ 'text' : msg,
46 \ 'bufnr': bufnr(''),
47 \ 'type': 'E' })
48 endfor
49 return result
50 endif
51 return []
52endfunction