From 8be560abe1b0486188573d10d1ff10b8cf7b6ff1 Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Wed, 27 Oct 2021 09:36:22 +0200 Subject: [PATCH] nvimrc: switch to nvim-cmp plugin --- nvimrc | 96 ++++++++++++++-------------------------------------------- 1 file changed, 23 insertions(+), 73 deletions(-) diff --git a/nvimrc b/nvimrc index 9d3f4e4..fc9d095 100644 --- a/nvimrc +++ b/nvimrc @@ -68,7 +68,7 @@ set updatetime=250 set pastetoggle= set pumheight=200 " Required for nvim-compe: -set completeopt=menuone,noselect +set completeopt=menu,menuone,noselect set complete-=i set nrformats-=octal set ttimeout @@ -768,80 +768,30 @@ nvim_lsp.sumneko_lua.setup { } EOF -" nvim-compe: +" nvim-cmp: -packadd! nvim-compe " https://github.com/hrsh7th/nvim-compe -packadd! compe-tmux " https://github.com/andersevenrud/compe-tmux +packadd! nvim-cmp " https://github.com/hrsh7th/nvim-cmp.git +packadd! cmp-nvim-lsp " https://github.com/hrsh7th/cmp-nvim-lsp.git +packadd! cmp-buffer " https://github.com/hrsh7th/cmp-buffer.git +packadd! cmp-path " https://github.com/hrsh7th/cmp-path.git +packadd! cmp-calc " https://github.com/hrsh7th/cmp-calc lua < compe#confirm('') -inoremap compe#close('') -inoremap compe#scroll({ 'delta': +4 }) -inoremap compe#scroll({ 'delta': -4 }) - -" TAB navigation support: -lua <" - elseif check_back_space() then - return t "" - else - return vim.fn['compe#complete']() - end -end -_G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - else - return t "" - end -end - -vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) + cmp.setup({ + mapping = { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ select = true }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'calc' }, + }) + }) EOF