This is my setup.
~/.config/nvim/rocks.toml
[plugins]
"rocks.nvim" = "2.42.2"
nvim-cmp = "scm"
cmp-buffer = "scm"
cmp-nvim-lsp = "scm"
...
~/.config/nvim/plugin/autocompletion/init.lua
require('cmp').setup()
require('cmp_nvim_lsp').setup()
This is my setup.
~/.config/nvim/rocks.toml
[plugins]
"rocks.nvim" = "2.42.2"
nvim-cmp = "scm"
cmp-buffer = "scm"
cmp-nvim-lsp = "scm"
...
~/.config/nvim/plugin/autocompletion/init.lua
require('cmp').setup()
require('cmp_nvim_lsp').setup()
Autocompletion without configuration doesn’t work.
~/.config/nvim/plugin/autocompletion/init.lua
require('cmp').setup({
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
mapping = {
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.select_next_item(),
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
},
sources = {
{ name = 'path' },
{ name = 'nvim_lsp', keyword_length = 3 },
{ name = 'buffer', keyword_length = 2 },
},
})
require('cmp_nvim_lsp').setup()