From 7671090a24afd3271a1505927468430c7b3012e1 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 4 May 2025 21:50:57 +0200 Subject: modules/nvim/plgs/luasnip: Provide key mappings These make jumping through snippets possible --- modules/by-name/nv/nvim/plgs/luasnip/default.nix | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'modules/by-name/nv/nvim/plgs/luasnip/default.nix') diff --git a/modules/by-name/nv/nvim/plgs/luasnip/default.nix b/modules/by-name/nv/nvim/plgs/luasnip/default.nix index e7c006a6..8e445d40 100644 --- a/modules/by-name/nv/nvim/plgs/luasnip/default.nix +++ b/modules/by-name/nv/nvim/plgs/luasnip/default.nix @@ -16,6 +16,62 @@ cfg = config.soispha.programs.nvim; in { home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable { + keymaps = [ + { + key = ""; + mode = ["i"]; + action.__raw = '' + function() + require('luasnip').expand() + end + ''; + options = { + # silent = true; + desc = "Expand the snippet"; + }; + } + { + key = ""; + mode = ["i" "s"]; + action.__raw = '' + function() + require('luasnip').jump(1) + end + ''; + options = { + # silent = true; + desc = "Jump forward in snippet insert nodes"; + }; + } + { + key = ""; + mode = ["i" "s"]; + action.__raw = '' + function() + require('luasnip').jump(-1) + end + ''; + options = { + # silent = true; + desc = "Jump backwards in snippet insert nodes"; + }; + } + { + key = ""; + mode = ["i" "s"]; + action.__raw = '' + function() + if require('luasnip').choice_active() then + require('luasnip').change_choice(1) + end + end + ''; + options = { + # silent = true; + desc = "Cycle through the snippets choice nodes"; + }; + } + ]; plugins.luasnip = { enable = true; -- cgit 1.4.1