2009-11-24 04:55:05 -05:00
|
|
|
"============================================================================
|
|
|
|
"File: perl.vim
|
|
|
|
"Description: Syntax checking plugin for syntastic.vim
|
2012-05-31 04:26:08 -04:00
|
|
|
"Maintainer: Anthony Carapetis <anthony.carapetis at gmail dot com>,
|
|
|
|
" Eric Harmon <http://eharmon.net>
|
2009-11-24 04:55:05 -05:00
|
|
|
"License: This program is free software. It comes without any warranty,
|
|
|
|
" to the extent permitted by applicable law. You can redistribute
|
|
|
|
" it and/or modify it under the terms of the Do What The Fuck You
|
|
|
|
" Want To Public License, Version 2, as published by Sam Hocevar.
|
|
|
|
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
|
|
|
"
|
|
|
|
"============================================================================
|
2012-06-29 19:01:49 -04:00
|
|
|
"
|
2013-09-29 10:29:21 -04:00
|
|
|
" Checker options:
|
2012-06-29 19:01:49 -04:00
|
|
|
"
|
2013-09-29 10:29:21 -04:00
|
|
|
" - g:syntastic_perl_interpreter (string; default: 'perl')
|
|
|
|
" The perl interpreter to use.
|
2012-06-29 19:01:49 -04:00
|
|
|
"
|
2013-09-29 10:29:21 -04:00
|
|
|
" - g:syntastic_perl_lib_path (list; default: [])
|
|
|
|
" List of include directories to be added to the perl command line. Example:
|
2012-08-02 19:25:52 -04:00
|
|
|
"
|
2013-09-29 10:29:21 -04:00
|
|
|
" let g:syntastic_perl_lib_path = [ './lib', './lib/auto' ]
|
2009-11-24 04:55:05 -05:00
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
if exists('g:loaded_syntastic_perl_perl_checker')
|
2013-02-21 10:50:41 -05:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_syntastic_perl_perl_checker=1
|
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
if !exists('g:syntastic_perl_interpreter')
|
|
|
|
let g:syntastic_perl_interpreter = 'perl'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !exists('g:syntastic_perl_lib_path')
|
|
|
|
let g:syntastic_perl_lib_path = []
|
2013-05-17 12:09:21 -04:00
|
|
|
endif
|
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
function! SyntaxCheckers_perl_perl_IsAvailable()
|
2013-05-17 12:09:21 -04:00
|
|
|
return executable(g:syntastic_perl_interpreter)
|
2013-01-27 15:08:30 -05:00
|
|
|
endfunction
|
2009-11-24 04:55:05 -05:00
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
function! SyntaxCheckers_perl_perl_Preprocess(errors)
|
|
|
|
let out = []
|
2012-12-18 04:35:21 -05:00
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
for e in a:errors
|
|
|
|
let parts = matchlist(e, '\v^(.*)\sat\s(.*)\sline\s(\d+)(.*)$')
|
|
|
|
if !empty(parts)
|
|
|
|
call add(out, parts[2] . ':' . parts[3] . ':' . parts[1] . parts[4])
|
|
|
|
endif
|
|
|
|
endfor
|
2009-11-24 04:55:05 -05:00
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
return syntastic#util#unique(out)
|
2009-11-24 04:55:05 -05:00
|
|
|
endfunction
|
2012-12-18 04:35:21 -05:00
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
function! SyntaxCheckers_perl_perl_GetLocList()
|
|
|
|
if type(g:syntastic_perl_lib_path) == type('')
|
|
|
|
call syntastic#util#deprecationWarn('variable g:syntastic_perl_lib_path should be a list')
|
|
|
|
let includes = split(g:syntastic_perl_lib_path, ',')
|
|
|
|
else
|
|
|
|
let includes = exists('b:syntastic_perl_lib_path') ? b:syntastic_perl_lib_path : g:syntastic_perl_lib_path
|
|
|
|
endif
|
2013-04-15 04:21:52 -04:00
|
|
|
let shebang = syntastic#util#parseShebang()
|
2013-09-29 10:29:21 -04:00
|
|
|
let extra = join(map(includes, '"-I" . v:val')) . (index(shebang['args'], '-T') >= 0 ? ' -T' : '')
|
|
|
|
let errorformat = '%f:%l:%m'
|
|
|
|
|
|
|
|
let makeprg = syntastic#makeprg#build({
|
|
|
|
\ 'exe': g:syntastic_perl_interpreter,
|
|
|
|
\ 'args': '-c -X ' . extra,
|
|
|
|
\ 'filetype': 'perl',
|
|
|
|
\ 'subchecker': 'perl' })
|
|
|
|
|
|
|
|
let errors = SyntasticMake({
|
|
|
|
\ 'makeprg': makeprg,
|
|
|
|
\ 'errorformat': errorformat,
|
|
|
|
\ 'preprocess': 'SyntaxCheckers_perl_perl_Preprocess',
|
|
|
|
\ 'defaults': {'type': 'E'} })
|
|
|
|
if !empty(errors)
|
|
|
|
return errors
|
2012-12-18 04:35:21 -05:00
|
|
|
endif
|
|
|
|
|
2013-09-29 10:29:21 -04:00
|
|
|
let makeprg = syntastic#makeprg#build({
|
|
|
|
\ 'exe': g:syntastic_perl_interpreter,
|
|
|
|
\ 'args': '-c -Mwarnings ' . extra,
|
|
|
|
\ 'filetype': 'perl',
|
|
|
|
\ 'subchecker': 'perl' })
|
|
|
|
|
|
|
|
return SyntasticMake({
|
|
|
|
\ 'makeprg': makeprg,
|
|
|
|
\ 'errorformat': errorformat,
|
|
|
|
\ 'preprocess': 'SyntaxCheckers_perl_perl_Preprocess',
|
|
|
|
\ 'defaults': {'type': 'W'} })
|
2012-12-18 04:35:21 -05:00
|
|
|
endfunction
|
2013-01-27 15:08:30 -05:00
|
|
|
|
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
|
|
|
\ 'filetype': 'perl',
|
|
|
|
\ 'name': 'perl'})
|