From 15527910c321f3a6a01e1216442f8d21e5f19247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maria=20Jos=C3=A9=20Solano?= Date: Fri, 8 Nov 2024 04:40:25 -0800 Subject: [PATCH] fix(snippet): don't set navigation mappings in nightly (#4375) ## Description Since [this commit in Neovim](https://github.com/neovim/neovim/pull/27339), snippet navigation mappings are set by default to `` and ``, and hence don't need to be redefined here. Moreover, the core implementation makes sure that those snippet navigation mappings are active only when snippet expansion is happening, and if other user bindings are using those keys, they're restored when snippet navigation ends. ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- lua/lazyvim/plugins/coding.lua | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 34a747ea..8f1d7968 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -105,26 +105,17 @@ return { table.insert(opts.sources, { name = "snippets" }) end end, - keys = { - { - "", - function() + init = function() + -- Neovim enabled snippet navigation mappings by default in v0.11 + if vim.fn.has("nvim-0.11") == 0 then + vim.keymap.set({ "i", "s" }, "", function() return vim.snippet.active({ direction = 1 }) and "lua vim.snippet.jump(1)" or "" - end, - expr = true, - silent = true, - mode = { "i", "s" }, - }, - { - "", - function() + end, { expr = true, silent = true }) + vim.keymap.set({ "i", "s" }, "", function() return vim.snippet.active({ direction = -1 }) and "lua vim.snippet.jump(-1)" or "" - end, - expr = true, - silent = true, - mode = { "i", "s" }, - }, - }, + end, { expr = true, silent = true }) + end + end, }, -- auto pairs