VIM/Python:将值从Python返回到VIM(通过堆栈)

VIM/Python:将值从Python返回到VIM(通过堆栈),python,vim,Python,Vim,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 我试图用py

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
我试图用python(C-XC-O)编写一个全方位的函数。第一次调用函数时:

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.
我希望避免首先传递到a:findstart,然后保存到l:findstart(所有这些都在包装器中),然后读取l:findstart并在python模块中处理它——最后返回l:start或空列表。试图管理一个“全局”变量并在不同的地方切换它是一件痛苦的事情


是否有某种方法可以直接从python模块返回值,而无需执行vimscript:returnl:start。如何直接从python w.r.tomnifunccompletefunc

处理相关问题。您好,很遗憾,这不是我想要的:(但感谢您的链接。此链接涉及范围-您可以使用python3这一事实听起来很相似,但涉及访问python/vim变量sInVim-这是一个标准的范围界定问题。这两个链接都很有用,但没有解决我的问题,这是关于内部Vimscript堆栈的问题!正在使用某些参数调用vim函数通过堆栈传递。当我“返回”一个值时,它再次通过堆栈传递-这与访问sInVim不同,sInVim似乎是局部作用域-我不确定..我想知道的是是否有方法绕过堆栈传递。
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.