From f6cd2eee6c510eff652191633d0cb2134a4f355f Mon Sep 17 00:00:00 2001 From: afonsofrancof Date: Sat, 14 Jan 2023 04:32:16 +0000 Subject: [PATCH] [MINOR] Added and to navigate snippet fields --- .config/nvim/lua/plugins/cmp.lua | 21 +++++++++++++++++++-- .config/nvim/lua/plugins/lazy.lua | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 1263fc1..262a018 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -52,8 +52,6 @@ cmp.setup { end, }, mapping = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), @@ -64,6 +62,25 @@ cmp.setup { }, -- Accept currently selected item. If none selected, do nothing. [""] = cmp.mapping.confirm { select = false }, + [""] = cmp.mapping(function(fallback) + if luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end + ), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() diff --git a/.config/nvim/lua/plugins/lazy.lua b/.config/nvim/lua/plugins/lazy.lua index fd672f2..7c320df 100644 --- a/.config/nvim/lua/plugins/lazy.lua +++ b/.config/nvim/lua/plugins/lazy.lua @@ -52,6 +52,7 @@ lazy.setup({ 'hrsh7th/cmp-path', --path completions 'hrsh7th/cmp-cmdline', --cmdline completions 'L3MON4D3/LuaSnip', + 'rafamadriz/friendly-snippets', 'saadparwaiz1/cmp_luasnip', }, config = function()