From 82d6258d6688e3e188e71350d73a75e3bfa2b08b Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Thu, 27 Jun 2024 14:35:13 +0000 Subject: [PATCH] feat(cmp): press `/` to jump in snippets --- lua/modules/configs/completion/cmp.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 37b68ea0b..3220aa8a4 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -127,13 +127,21 @@ return function() }, -- You can set mappings if you want mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select, count = 1 }), [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select, count = 1 }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select, count = 1 }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.abort(), - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select, count = 1 }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select, count = 1 }), + [""] = cmp.mapping(function() + if require("luasnip").expand_or_locally_jumpable() then + require("luasnip").expand_or_jump() + end + end, { "i", "s" }), + [""] = cmp.mapping(function() + if require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + end + end, { "i", "s" }), [""] = cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then