diff --git a/.config/nvim/plugin/cmp.lua b/.config/nvim/plugin/cmp.lua index ff9b5216..3fc67eb3 100644 --- a/.config/nvim/plugin/cmp.lua +++ b/.config/nvim/plugin/cmp.lua @@ -7,14 +7,29 @@ cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, - mapping = cmp.mapping.preset.insert(), + mapping = cmp.mapping.preset.insert { + [""] = cmp.mapping(function(fallback) + if luasnip.locally_jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, sources = cmp.config.sources({ - { name = "luasnip" }, - { name = "nvim_lsp" }, - { name = "path" }, - }, - { - { name = "buffer" }, - { name = "spell", }, - }), + { name = "luasnip" }, + { name = "nvim_lsp" }, + { name = "path" }, + }, { + { name = "buffer" }, + { name = "spell" }, + }), }