Improves the Perl syntax checker to include lib
In .vimrc, you can specify the path for the libraries using : let g:perl_lib_path = './lib'
This commit is contained in:
parent
1e94b98705
commit
f67266e2f5
@ -70,11 +70,11 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use Getopt::Std;
|
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;
|
use constant VERSION => 0.2;
|
||||||
|
|
||||||
getopts('cwf:h');
|
getopts('cwf:hI:');
|
||||||
|
|
||||||
&usage if $opt_h; # not necessarily needed, but good for further extension
|
&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 $file = shift) or &usage; # display usage if no filename is supplied
|
||||||
my $args = (@ARGV ? ' ' . join ' ', @ARGV : '');
|
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 @lines = map { "E:$_" } @error_lines;
|
||||||
|
|
||||||
my @warn_lines;
|
my @warn_lines;
|
||||||
if(defined($opt_w)) {
|
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
|
# Any new errors must be warnings
|
||||||
@ -153,6 +153,7 @@ Usage:
|
|||||||
-c compile only, don't run (executes 'perl -c')
|
-c compile only, don't run (executes 'perl -c')
|
||||||
-w output warnings as warnings instead of errors (slightly slower)
|
-w output warnings as warnings instead of errors (slightly slower)
|
||||||
-f write errors to <errorfile>
|
-f write errors to <errorfile>
|
||||||
|
-I specify \@INC/#include directory <perl_lib_path>
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
* At the command line:
|
* At the command line:
|
||||||
|
@ -10,6 +10,13 @@
|
|||||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
" 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")
|
if exists("loaded_perl_syntax_checker")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
@ -24,7 +31,11 @@ endif
|
|||||||
let s:checker = 'perl ' . shellescape(expand('<sfile>:p:h') . '/efm_perl.pl') . ' -c -w'
|
let s:checker = 'perl ' . shellescape(expand('<sfile>:p:h') . '/efm_perl.pl') . ' -c -w'
|
||||||
|
|
||||||
function! SyntaxCheckers_perl_GetLocList()
|
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'
|
let errorformat = '%t:%f:%l:%m'
|
||||||
|
|
||||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user