2016-07-18 30 views
0

我正在使用neovim和deoplete自动补全插件。我不喜欢自动自动完成,所以我试图完成使用<Tab>工作。由于文档提示:Vim:调用自定义函数中的对象方法

inoremap <silent><expr> <Tab> 
    \ pumvisible() ? "\<C-n>" : deoplete#manual_complete() 

这个伟大的工程......除了<Tab>已经不缩进即使我在一行的开始(或有光标下方的空间)。我写了一个函数(很差)来解决这个问题:

function! Smart_TabComplete() 
    if pumvisible() 
     return "^N" 
    endif 
    let line = getline('.')       " current line 

    let substr = strpart(line, -1, col('.')+1)  " from the start of the current 
    " line to one character right 
    " of the cursor 
    let spaces = strpart(line, -1, col('.')) 

    let substr = matchstr(substr, '[^ \t]*$')  " word till cursor 
    let spaces = matchstr(spaces, '[^ \t]*$') 
    if (strlen(substr)==0)       " nothing to match on empty string 
     return "  " 
    endif 
    if (strlen(spaces)==0)       " nothing to match on empty string 
     return "  " 
    endif 
    deoplete#manual_complete() 
endfunction 

我把这个代替deoplete#manual_complete()以上。貌似这样可以修复使用<Tab>的缩进问题,但现在里面的功能我总是得到:

Not an editor command: deoplete#manual_complete()

我真的不知道该怎么办这件事,我甚至试过路过deoplete作为参数Smart_TabComplete,但它不起作用。

  • 有没有更好的方法使用<Tab>自动完成和间距?
  • 否则,我如何在自定义函数中调用deoplete#manual_complete()

回答

1

使用:call命令来调用函数。

call deoplete#manual_complete() 

如果您需要返回的deoplete#manual_complete()的结果,然后使用:return

return deoplete#manual_complete() 

如需更多帮助,请参见:

:h :call 
:h :return 
+0

这不会导致调用该函数,但它似乎只需使用函数“0”的返回值,而不是实际代理到“deoplete”函数调用。有什么建议么? –