From b47ef5fbe0bed1065f9b6dfd73996bf1d74fc2a0 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Wed, 31 Jul 2024 21:24:28 +0700 Subject: [PATCH] cmp: finally fix the annoying tab jump issue --- lua/config/keymaps.lua | 4 ---- lua/plugins/luasnip.lua | 45 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 983ae3e..cf61f1e 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -6,10 +6,6 @@ require "config.neovide" vim.keymap.set("t", "", "", { silent = true, desc = "Exit Terminal Mode" }) --- LazyVim hardcode tabs to jump snippet completions. Very fucking annoying. -vim.keymap.del({ "i" }, "") -vim.keymap.del({ "i" }, "") - vim.keymap.set( "n", "z", diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua index b0c3d42..d0f3748 100644 --- a/lua/plugins/luasnip.lua +++ b/lua/plugins/luasnip.lua @@ -1,7 +1,42 @@ return { - "L3MON4D3/LuaSnip", - opts = function(_, opts) - require "snippets" - return opts - end, + { + "L3MON4D3/LuaSnip", + opts = function(_, opts) + require "snippets" + return opts + end, + }, + { + "nvim-cmp", + keys = { + { + "", + false, + mode = "i", + }, + { + "", + function() + return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + end, + expr = true, + silent = true, + mode = { "i", "s" }, + }, + { + "", + function() + return require("luasnip").jumpable(-1) and "luasnip-jump-prev" or "" + end, + expr = true, + silent = true, + mode = "i", + }, + { + "", + false, + mode = { "i" }, + }, + }, + }, }