Actually, as I discovered after posting, it's a lot easier to write a Compile() function that you get to control (like adding -Ilib) than depending on vim's make. So, I took that out. Plus, I found a few things better than BufNewFile and BufRead.
This is how my .exrc snippet looks now:
autocmd BufNewFile,BufRead *.p? so ~/.vim/perltest.vim
autocmd BufEnter *.p? colors peachpuff
autocmd BufNewFile,BufRead *.t so ~/.vim/perltest.vim
autocmd BufEnter *.t colors blue
And, I make a few changes to my perltest.vim
" perltest.vim - test driven development for Perl with vim
"
" ,t -- Run tests
" ,w -- Set current file as test file. Only this test will run.
" ,W -- Unset current test file. All tests will run.
"
" Updates at http://perlmonks.org/index.pl?node_id=434793
function! Prove ( verbose )
if ! exists("g:testfile")
let g:testfile = "t/"
endif
if g:testfile == "t/" || g:testfile =~ "\.t$"
if a:verbose
echo system("prove -vl " . g:testfile . " 2>&1 | tee " . &
+errorfile)
else
echo system("prove -l " . g:testfile . " 2>&1 | tee " . &e
+rrorfile)
endif
else
call Compile ()
endif
cfile
endfunction
function! Compile ()
if ! exists("g:compilefile")
let g:compilefile = expand("%")
endif
execute "!perl -wc -Ilib " . g:compilefile
cfile
endfunction
nmap ,t :call Prove (0)<cr>
nmap ,T :call Prove (1)<cr>
nmap ,v :call Compile ()<cr>
nmap ,w :let g:testfile = expand("%")<cr>:echo "testfile is now" g:t
+estfile<cr>
nmap ,W :unlet g:testfile<cr>:echo "testfile undefined; will run all t
+ests"<cr>
" based on compiler/perl.vim by Christian J. Robinson <infynity@onewes
+t.net>
" added formats for test failures
set errorformat=
\%-G%.%#had\ compilation\ errors.,
\%-G%.%#syntax\ OK,
\%+Anot\ ok\%.%#-\ %m,
\%C%.%#\(%f\ at\ line\ %l\),
\%m\ at\ %f\ line\ %l.,
\%+A%.%#\ at\ %f\ line\ %l\\,%.%#,
\%+C%.%#
" FIXME make this more local. Needed for redirection syntax which isn'
+t csh compatible
set sh=/bin/sh
" Just more convenient when shelling out a lot.
set autowrite
The main changes are:
- Addition of ,T allowing for make test TEST_VERBOSE=1
- Addition of ,v allowing for compile of .t files. This entailed creating Compile()
- Addition of -l flag to prove, keeping the vim editor in the same directory as the tags file.
I'm still figuring out the various parameters. Heck, I've learned more about the vim settings in the last hour than I had in the 10+ years I've been using vi-based editors! :-)
Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.