VIM: Perl interface, passing a variable to Perl and reading a vim variable from Perl
I use a Perl(loader.vim) script to load VIM modules: (.vimrc) source /whatever/loader.vim
loader.vim:
function! LoadBundles() perl HERE while(</root/.vim/bundle/*/plugin/*&开发者_StackOverflowgt;) { my ($path, $fname) =($_ =~ m|^(.+/)(.+?)$|); #VIM::Msg("$path $fname\n"); VIM::DoCommand("set runtimepath=$path"); VIM::DoCommand("runtime! $fname"); } HERE endfunction call LoadBundles()
I'd like to do something like LoadBundles('/path/to/bundledir') but to do this I need to be able to read a variable from within Perl eg:
function! LoadBundles(path) let var = a:path perl HERE print "$var\n";
How do I do this???
I'd also like to save the runtimepath within perl HERE and then restore it. How do I read runtimepath from within perl HERE?
Here's how you can get at the "runtimepath" option from embedded Perl:
perl VIM::Msg( VIM::Eval('&runtimepath') )
Do the following to get more from the docs:
:help if_perl.txt
Then search for "VIM::Eval". So try:
function! AnExample(arg)
perl << EOF
VIM::Msg( VIM::Eval('a:arg') )
EOF
endfunction
And then to test:
:so %
:call AnExample("hello")
精彩评论