From 6aa4c24d02b3ef67fc5cdc07a0d1fdee583f9ba4 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Tue, 27 Aug 2024 15:25:58 +0200 Subject: [PATCH] add neovim snippets --- home/base/programs/nixvim/default.nix | 34 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/home/base/programs/nixvim/default.nix b/home/base/programs/nixvim/default.nix index 81de6a7..d818c70 100644 --- a/home/base/programs/nixvim/default.nix +++ b/home/base/programs/nixvim/default.nix @@ -196,13 +196,36 @@ "" = "cmp.mapping.close()"; "" = "cmp.mapping.scroll_docs(4)"; "" = "cmp.mapping.confirm({ select = true })"; - "" = - "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; - "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = '' + cmp.mapping(function (fallback) + local luasnip = require('luasnip') + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {'i', 's'}) + ''; + "" = '' + cmp.mapping(function (fallback) + local luasnip = require('luasnip') + if luasnip.expandable() then + luasnip.expand() + elseif cmp.visible() then + cmp.select_next_item() + elseif luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, {'i', 's'}) + ''; }; sources = - [ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } ]; + [ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } { name = "luasnip"; } ]; }; }; cmp-nvim-lsp.enable = true; @@ -211,6 +234,9 @@ enable = true; }; + luasnip.enable = true; + friendly-snippets.enable = true; + neo-tree = { enable = true; useDefaultMappings = true;