Contents of wrapper.vim
func! Auto_complete(findstart, base)
let l:start = a:findstart
let l:base = a:base
let l:res = []
python3 << EOF
import ac
ac.__main__()
EOF
if a:findstart #YUCK
return l:start
endfunction
Contents of actual implementation def main(): import vim
base = vim.eval('a:base')
findstart = vim.eval('a:findstart')
# First invocation:
# findstart set to 1 and base is empty return int
# between 0 and cursor_column, to indicate part of text between
# return_position and cursor_column which is to be replaced
if findstart == 1:
set_position()
else: # findstart == 0 and base = replacement_text
feed_replacement_text()
I'm trying to write an omnicomplete function in python (C-X C-O). The first time the function is called:
On the first invocation the arguments are:
a:findstart 1
a:base empty
On the second invocation the arguments are:
a:findstart 0
a:base the text with which matches should match; the text that was
located in the first call (can be empty)
The function must return a List with the matching words. These matches
usually include the "a:base" text. When there are no matches return an empty
List.
I want to avoid first passing to a:findstart, then saving to l:findstart (all this within the wrapper), then reading l:findstart and messing with it within the python module - finally doing a return l:start or a empty list. Trying to manage a 'global' variable and toggling it from different places is a pain.
Is there some way I can return values directly from the python module without ever doing a vimscript: return l:start. How do I deal directly from python w.r.t omnifunc and completefunc