NAME
Devel::IntelliPerl::Editor::Vim - IntelliPerl integration for Vim
VERSION
version 0.04
SYNOPSIS
Pressing <c-x><c-o> from insert mode in Vim will offer up a menu to auto complete with either a_method
or a_varaible
.
DESCRIPTION
Vim uses the omnifunction to autocomplete most languages. This is typically mapped to <c-x><c-o>
which is vim speak for (ctrl-x followed by crtl-o). Add the following to your ~/.vim/ftplugin/perl.vim
file and the omnifunction should run Devel::IntelliPerl for perl method completion.
setlocal omnifunc=Ocf_devel_intelliperl
function! Ocf_devel_intelliperl(findstart, base)
" This function is called twice, once
with
a:findstart and immediately
" thereafter without a:findstart
" With a:findstart,
return
the col where the prefix starts
" Without a:findstart,
return
the method options
" We run Devel::IntelliPerl only once and cache the results
if
a:findstart
" Get some info
for
the command
let line = line(
'.'
)
let column = col(
'.'
) - 1
let filename = expand(
"%"
)
" Defined the Devel::IntelliPerl command
let command =
"perl -MDevel::IntelliPerl::Editor::Vim -e 'run' "
. line .
' '
. column .
' '
. filename
" Get the current contents of the buffer (we don't want to have to
write
the file)
let buffer_contents =
join
( getline(1,
"$"
),
"\n"
)
" Run the command and munge the results into a list
let result_str =
system
(command, buffer_contents )
let s:ofc_results =
split
( result_str,
" *\n"
)
let prefix_len = s:ofc_results[0]
return
col(
'.'
) - prefix_len - 1
endif
return
s:ofc_results[1:-1]
endfunction
METHODS
editor
Set to Vim
.
run
This method is exported and invokes Devel::IntelliPerl.
SEE ALSO
COPYRIGHT & LICENSE
Copyright 2009 Mark Grimes, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.