Closed languitar closed 6 years ago
Interesting! I've noticed that ncm2 has been announced, but I'm currently using deoplete and will probably not change again very soon as I'm happy for now. As such, I don't really have the time to investigate the necessary configuration. I would be very happy if you/someone could help me by proposing text for the docs.
The following (stolen from reddit) works for me:
" include the following plugins (here using junnegun/vim-plug)
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2'
au User Ncm2Plugin call ncm2#register_source({
\ 'name' : 'vimtex',
\ 'priority': 9,
\ 'subscope_enable': 1,
\ 'complete_length': 1,
\ 'scope': ['tex'],
\ 'mark': 'tex',
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
(there are other options for convenience; see https://github.com/ncm2/ncm2#optional-vimrc-tips)
It feels a bit snappier than deoplete
(and less prone to race conditions, i.e., \de
showing \dagger
if the e
is typed too quickly after d
), although there are some (cosmetic) regressions regarding the (optional and still experimental) integration with UltiSnips (already fixed!).
(One difference is that ncm2
is opt-in rather than opt-out like deoplete
, so every source has to be explicitly set up. E.g., for Ultisnips you have to add Plug 'ncm2/ncm2-ultisnips'
, but then it works without further configuration. There's a corresponding plugin for snipmate
.)
@clason I tried exactly that code but I can't get completions for tex with this. Any idea?
@languitar Here's a minimal vimrc
that works for me:
call plug#begin('~/.vim/plugged')
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2'
Plug 'lervag/vimtex'
call plug#end()
au User Ncm2Plugin call ncm2#register_source({
\ 'name' : 'vimtex',
\ 'priority': 1,
\ 'subscope_enable': 1,
\ 'complete_length': 1,
\ 'scope': ['tex'],
\ 'mark': 'tex',
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm,
\ 'on_complete': ['ncm2#on_complete#omni',
'vimtex#complete#omnifunc'],
\ })
au BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
First thing is to check your neovim
version (I'm on NVIM v0.3.1-172-g56065bbdc
) and make sure that the python integration is working (:checkhealth
, and if in doubt, pip3 install -U --force neovim
). Another thought: Maybe your file is not recognized as tex
(:se ft=tex
to make sure)?
Or, more likely, something in your vimrc
interferes with the ncm2#enable()
call. If you manually call this function after the buffer is loaded, does it work then?
Thanks! I've added a section on this now. What do you think?
Looks good!
@clason seems there was an update to ncm2 that I was missing. Now it works.
Just a heads-up: Recent commits changed the sorting and matching algorithm to fuzzy matching; to get the old, prefix-based, behaviour, you have to add the following line to the custom source:
\ 'matcher': {'name': 'prefix', 'key': 'word'},
I'll make a pull request for the documentation.
Thanks!
neovim-completion-manager got replaced by ncm2. Some calls to register custom completions have changed with this. I am still struggling to get vimtex completion working here. Some documentation would be nice.