Reputation: 191799
I'm using neovim with the deoplete autocompletion plugin. I don't like the auto-auto complete, so I am trying to get completion to work using <Tab>
. As the docs suggest:
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" : deoplete#manual_complete()
This works great ... except that <Tab>
does not indent anymore even if I am at the start of a line (or there is a space under the cursor). I've written a function (poorly) to get around this:
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
I call this instead of deoplete#manual_complete()
above. Seemingly this fixes the using <Tab>
for indent problem, but now inside the function I always get:
Not an editor command: deoplete#manual_complete()
I'm not really sure what to do about this, and I even tried passing deoplete
in as an argument to Smart_TabComplete
, but it doesn't work.
<Tab>
for both autocomplete and spacing?deoplete#manual_complete()
in my custom function?Upvotes: 0
Views: 102
Reputation: 45167
Use the :call
command to call a function.
call deoplete#manual_complete()
If you need to return the results of deoplete#manual_complete()
then use :return
:
return deoplete#manual_complete()
For more help see:
:h :call
:h :return
Upvotes: 1