From 2eab84f8f19060c7fa3813b817432d6b3cc5298c Mon Sep 17 00:00:00 2001 From: socialsmoker223 Date: Tue, 1 Feb 2022 21:06:01 +0800 Subject: [PATCH] lunasnip super-tab like mapping example from hrsh7th/nvim-cmp --- lua/plugins/configs/cmp.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index 936779c..a958e74 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -41,24 +41,24 @@ local default = { behavior = cmp.ConfirmBehavior.Replace, select = true, }, - [""] = function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif snippets_status and require("luasnip").expand_or_jumpable() then - vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + require("luasnip").expand_or_jump() else fallback() end - end, - [""] = function(fallback) + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif snippets_status and require("luasnip").jumpable(-1) then - vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) else fallback() end - end, + end, { "i", "s" }), }, sources = { { name = "nvim_lsp" },