From e547afc985bcf86784b789b981f4fe42a1407144 Mon Sep 17 00:00:00 2001 From: Ceredril <63151691+Ceredril@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:51:40 +0100 Subject: [PATCH] Add snippet navigation Adds the usage of Tab and Shift-Tab to jump through parts of the snippet after selecting one. Pretty essential --- .config/nvim/lua/josean/plugins/nvim-cmp.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.config/nvim/lua/josean/plugins/nvim-cmp.lua b/.config/nvim/lua/josean/plugins/nvim-cmp.lua index 0947011..c6f88d5 100644 --- a/.config/nvim/lua/josean/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/josean/plugins/nvim-cmp.lua @@ -42,6 +42,22 @@ return { [""] = cmp.mapping.complete(), -- show completion suggestions [""] = cmp.mapping.abort(), -- close completion window [""] = cmp.mapping.confirm({ select = false }), + [""] = cmp.mapping(function(fallback) -- next part of snippet + if luasnip.expandable() then + luasnip.expand() + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s" }), -- in both insert and select mode + [""] = cmp.mapping(function(fallback) -- previous part of snippet + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), -- in both insert and select mode }), -- sources for autocompletion sources = cmp.config.sources({