diff options
author | xengineering <me@xengineering.eu> | 2024-02-27 16:01:42 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-02-27 16:01:42 +0100 |
commit | 56d112de5a943929a8580cc9aaf9443c656aae59 (patch) | |
tree | 222d64e8839cd1535592f4e0c2f34c4d61cf09f2 | |
parent | 2a06f4b24af76c2f3daeca374f52960e4cf30eb4 (diff) | |
download | dotfiles-56d112de5a943929a8580cc9aaf9443c656aae59.tar dotfiles-56d112de5a943929a8580cc9aaf9443c656aae59.tar.zst dotfiles-56d112de5a943929a8580cc9aaf9443c656aae59.zip |
nvim: Configure auto-completion
-rw-r--r-- | nvim/init.lua | 31 |
1 files changed, 30 insertions, 1 deletions
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', '<F6>', ':%!xxd <LF>') 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({ + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.abort(), + ['<CR>'] = 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 +} |