From f45bae9a14b526e65e66693cf1a4ee6f74001793 Mon Sep 17 00:00:00 2001 From: Brahmajit Das Date: Wed, 4 Jun 2025 03:57:54 +0530 Subject: lua: plugins: completion: autocompletion pop up matching with upstream docs Signed-off-by: Brahmajit Das --- lua/plugins/completion.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua index 6663a1b..e869758 100644 --- a/lua/plugins/completion.lua +++ b/lua/plugins/completion.lua @@ -85,10 +85,19 @@ return { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ + select = true, + }) + end + else + fallback() + end + end), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() -- cgit v1.2.3