diff options
Diffstat (limited to 'lua/plugins')
-rw-r--r-- | lua/plugins/completion.lua | 17 |
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() |