I recently transitioned from LanguageClient-neovim to built-in lsp support and completion using omnifunc. However I was enticed by the promise of auto-imports and completion snippets including function arguments, so I've been trying to integrate nvim-cmp. It requires a snippet engine so I installed vsnip, which seems to be working fine. However autocomplete is not working.
No matter what I do, it won't recognize any of the completion sources I try to install.
I don't see any errors at any point, it just seems to be silently failing; autocomplete does not appear when I type.
Here is the output from running CmpStatus
:
# unknown source names
- nvim_lsp
I'm not sure what other debugging options are available to me at this point other than print-debugging the cmp plugin.
I have installed the following relevant plugins using pathogen:
- cmp-nvim-lsp
- cmp-vsnip
- nvim-cmp
- nvim-lspconfig
- vim-vsnip
- vim-vsnip-integ
I have gradually pared down my config file to a (hopefully reasonably) minimal representation, including removing all of the sources and mappings I tried to configure for nvim-cmp except lsp support:
syntax on
filetype plugin indent on
set runtimepath=$HOME/.config/vim,$VIMRUNTIME
execute pathogen#infect()
execute pathogen#helptags()
map / <leader>
" lsp """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('nvim')
lua << EOF
vim.o.completeopt = 'menu,menuone,noselect'
local nvim_lsp = require('lspconfig')
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
vim.fn['vsnip#anonymous'](args.body)
end,
},
mapping = {
--['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
--['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
--['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
--['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
--['<C-e>'] = cmp.mapping({
-- i = cmp.mapping.abort(),
-- c = cmp.mapping.close(),
--}),
--['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
}),
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
local servers = { 'metals', 'tsserver', 'rls', 'vimls' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
capabilities = capabilities,
}
end
EOF
endif
" end lsp """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Here is the output from nvim --version
:
:$ nvim --version
NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210702-21950-fs4dxz/neovim-0.5.0/build/config -I/tmp/neovim-20210702-21950-fs4dxz/neovim-0.5.0/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210702-21950-fs4dxz/neovim-0.5.0/build/src/nvim/auto -I/tmp/neovim-20210702-21950-fs4dxz/neovim-0.5.0/build/include
Compiled by brew@iMac-Pro
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.0/share/nvim"
Run :checkhealth for more info