From 3eb89471c4b46521b069de9acd16d23dba886d81 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 29 Sep 2023 10:25:59 +0200 Subject: good complete --- .config/nvim/after/plugin/lsp.lua | 57 ++++++++++++++++++++++++++++++++++++--- .config/nvim/lua/bindings.lua | 6 +++-- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index 227e2eb..1056274 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -40,11 +40,60 @@ require('mason-lspconfig').setup({ local cmp = require('cmp') local cmp_select = { behavior = cmp.SelectBehavior.Select } +cmp.setup({ + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }) +}) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = 'buffer' }, + }) + }) + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + local cmp_mappings = lsp.defaults.cmp_mappings({ - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.complete(), }) diff --git a/.config/nvim/lua/bindings.lua b/.config/nvim/lua/bindings.lua index 3db5aa6..53ad03b 100644 --- a/.config/nvim/lua/bindings.lua +++ b/.config/nvim/lua/bindings.lua @@ -1,8 +1,10 @@ vim.keymap.set('n', '', ':call nerdcommenter#Comment(0,"toggle")', { noremap = true, silent = true }) vim.keymap.set('n', '', ':', { noremap = true, silent = false }) vim.keymap.set('n', '', ':bprevious', { noremap = true, silent = true }) -vim.keymap.set('n', '', 'zz', { noremap = true, silent = false }) -vim.keymap.set('n', '', 'zz', { noremap = true, silent = false }) +vim.keymap.set('n', '', 'zz', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'zz', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'zz', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'zz', { noremap = true, silent = true }) vim.keymap.set('n', '', ':bnext', { noremap = true, silent = true }) vim.keymap.set('n', '', 'h', { noremap = true, silent = false }) vim.keymap.set('n', '', 'j', { noremap = true, silent = false }) -- cgit v1.2.3