From 1561c18d353446d15ccceeef21cb1293f1d31bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20L=C3=BCdecke?= Date: Sun, 16 Mar 2025 21:59:22 +0100 Subject: [PATCH] Completion nvim-cmp: modified shortcuts, added :/ and :: completion --- lua/config/nvim-cmp.lua | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua index 6d2014e..e28dd19 100644 --- a/lua/config/nvim-cmp.lua +++ b/lua/config/nvim-cmp.lua @@ -14,14 +14,22 @@ cmp.setup({ require('luasnip').lsp_expand(args.body) -- For `luasnip` users. end, }, + + + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ -- Use to scroll the docs [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - -- Use to switch in items - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.complete(), + -- also scroll docs with page up / down + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + [''] = cmp.mapping.abort(), -- Use (Enter) to confirm selection -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. @@ -84,3 +92,24 @@ cmp.setup({ { name = 'sonicpi' }, -- for sonic-pi integration }) }) + + + +-- 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' } + }), + matching = { disallow_symbol_nonprefix_matching = false } +})