Complete the completion setup

This commit is contained in:
flyingscorpio@clevo 2022-08-13 12:54:02 +02:00
parent c9bfe21723
commit 03dc05a28c
2 changed files with 31 additions and 27 deletions

View file

@ -2,30 +2,33 @@
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
local cmp = require'cmp' local cmp = require'cmp'
if cmp then
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users. require('luasnip').lsp_expand(args.body)
end, end,
}, },
window = { window = {
-- completion = cmp.config.window.bordered(), -- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(), ['<C-e>'] = cmp.mapping.abort(),
['<Tab>'] = cmp.mapping.select_next_item(), ['<Tab>'] = cmp.mapping.select_next_item(),
['<S-Tab>'] = cmp.mapping.select_prev_item(), ['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lua' },
{ name = 'luasnip' }, { name = 'nvim_lsp' },
}, { { name = 'path' },
{ name = 'luasnip' },
{ name = 'buffer' }, { name = 'buffer' },
}) }),
}) experimental = { ghost_text = true }
})
end

View file

@ -22,9 +22,10 @@ return require('packer').startup(function(use)
-- Completion -- Completion
use 'hrsh7th/nvim-cmp' use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path' use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-nvim-lua'
use 'hrsh7th/cmp-nvim-lsp'
-- LuaSnip -- LuaSnip
use 'L3MON4D3/LuaSnip' use 'L3MON4D3/LuaSnip'