summaryrefslogtreecommitdiff
path: root/lua/plugins/completion.lua
diff options
context:
space:
mode:
authorBrahmajit Das <listout@listout.xyz>2025-06-04 03:57:54 +0530
committerBrahmajit Das <listout@listout.xyz>2025-06-04 03:57:54 +0530
commitf45bae9a14b526e65e66693cf1a4ee6f74001793 (patch)
tree6ee91f2d0af8cf718496c28e418057283f7a757c /lua/plugins/completion.lua
parent5d278e9b13e6dd4f43ac720f002a4a0d25ab5bc4 (diff)
lua: plugins: completion: autocompletion pop up matching with upstream docs
Signed-off-by: Brahmajit Das <listout@listout.xyz>
Diffstat (limited to 'lua/plugins/completion.lua')
-rw-r--r--lua/plugins/completion.lua17
1 files 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 {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
- ['<CR>'] = cmp.mapping.confirm {
- behavior = cmp.ConfirmBehavior.Insert,
- select = true,
- },
+ ['<CR>'] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ if luasnip.expandable() then
+ luasnip.expand()
+ else
+ cmp.confirm({
+ select = true,
+ })
+ end
+ else
+ fallback()
+ end
+ end),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()