diff --git a/syntax_checkers/efm_perl.pl b/syntax_checkers/efm_perl.pl index 3d75418c..865e170a 100644 --- a/syntax_checkers/efm_perl.pl +++ b/syntax_checkers/efm_perl.pl @@ -70,11 +70,11 @@ use strict; use Getopt::Std; -use vars qw/$opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars' +use vars qw/$opt_I $opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars' use constant VERSION => 0.2; -getopts('cwf:h'); +getopts('cwf:hI:'); &usage if $opt_h; # not necessarily needed, but good for further extension @@ -92,13 +92,13 @@ my $handle = (defined $opt_f ? \*FILE : \*STDOUT); (my $file = shift) or &usage; # display usage if no filename is supplied my $args = (@ARGV ? ' ' . join ' ', @ARGV : ''); -my @error_lines = `perl @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-w ']} "$file$args" 2>&1`; +my @error_lines = `perl @{[defined $opt_I ? "-I$opt_I" : '']} @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-w ']} "$file$args" 2>&1`; my @lines = map { "E:$_" } @error_lines; my @warn_lines; if(defined($opt_w)) { - @warn_lines = `perl @{[defined $opt_c ? '-c ' : '' ]} -w "$file$args" 2>&1`; + @warn_lines = `perl @{[defined $opt_I ? $opt_I : '']} @{[defined $opt_c ? '-c ' : '' ]} -w "$file$args" 2>&1`; } # Any new errors must be warnings @@ -153,6 +153,7 @@ Usage: -c compile only, don't run (executes 'perl -c') -w output warnings as warnings instead of errors (slightly slower) -f write errors to + -I specify \@INC/#include directory Examples: * At the command line: diff --git a/syntax_checkers/perl.vim b/syntax_checkers/perl.vim index 1d48f61c..fe8e4a68 100644 --- a/syntax_checkers/perl.vim +++ b/syntax_checkers/perl.vim @@ -10,6 +10,13 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ +" +" In order to add some custom lib directories that should be added to the +" perl command line you can add those to the global variable +" g:perl_lib_path. +" +" let g:perl_lib_path = './lib' +" if exists("loaded_perl_syntax_checker") finish endif @@ -24,7 +31,11 @@ endif let s:checker = 'perl ' . shellescape(expand(':p:h') . '/efm_perl.pl') . ' -c -w' function! SyntaxCheckers_perl_GetLocList() - let makeprg = s:checker . ' ' . shellescape(expand('%')) + if exists("g:perl_lib_path") + let makeprg = s:checker . ' -I' . g:perl_lib_path . ' ' . shellescape(expand('%')) + else + let makeprg = s:checker . ' ' . shellescape(expand('%')) + endif let errorformat = '%t:%f:%l:%m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })