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;