# HG changeset patch # User Meredith Howard # Date 1676856905 21600 # Node ID 589244a349f6b40019c90ee90c1d55ed47e5a066 # Parent b0497894f69b115dd035b054da3a60136a6460e9 tweak completion diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -39,17 +39,29 @@ return { mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.select_next_item(), + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + cmp.complete() + end + end, [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.abort(), - -- FIXME: add extra space after in select case? - [""] = cmp.mapping.confirm({select = false}), [""] = cmp.mapping.confirm({select = true}), + [""] = function(fallback) + if cmp.visible() then + cmp.confirm({select = false}) + vim.api.nvim_feedkeys(" ", "n", false) + end + fallback() + end, }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "nvim_lsp_signature_help" }, { name = "nvim_lua" }, + }, { { name = "buffer" }, { name = "path" }, }),