From 56d112de5a943929a8580cc9aaf9443c656aae59 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 27 Feb 2024 16:01:42 +0100 Subject: nvim: Configure auto-completion --- nvim/init.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/nvim/init.lua b/nvim/init.lua index 7760aac..9d50ab3 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -24,4 +24,33 @@ vim.keymap.set('n', '', ':%!xxd ') vim.cmd.highlight('SpellBad', 'ctermbg=Red') vim.cmd.highlight('SpellBad', 'ctermfg=Black') -require'lspconfig'.clangd.setup{} +local cmp = require'cmp' +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + }) +}) + +local capabilities = require('cmp_nvim_lsp').default_capabilities() +require'lspconfig'.clangd.setup{ + capabilities = capabilities +} -- cgit v1.2.3-70-g09d2