diff options
Diffstat (limited to '.config/nvim/lua/autocomplete.lua')
| -rw-r--r-- | .config/nvim/lua/autocomplete.lua | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/.config/nvim/lua/autocomplete.lua b/.config/nvim/lua/autocomplete.lua index 775a407..a86e86b 100644 --- a/.config/nvim/lua/autocomplete.lua +++ b/.config/nvim/lua/autocomplete.lua @@ -21,6 +21,28 @@ ['<C-Space>'] = cmp.mapping.complete(), ['<C-e>'] = cmp.mapping.abort(), ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + ["<Tab>"] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + feedkey("<C-n>", "n") + elseif cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { + "i", + }), + ["<S-Tab>"] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + feedkey("<C-p>", "n") + elseif cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { + "i", + }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, @@ -49,12 +71,11 @@ { 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' } - }) - }) + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) |
