2016-07-18 31 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」函數調用。有什麼建議麼? –