From 5d9cd9d835f3cec1feafb87e1b1ec58815875558 Mon Sep 17 00:00:00 2001 From: emmatherock Date: Fri, 4 Sep 2026 20:51:47 -0300 Subject: [PATCH] feat(neovim): add snippets, autopairs and surround --- home/emmatherock/neovim.nix | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/home/emmatherock/neovim.nix b/home/emmatherock/neovim.nix index 3d71290..6a65041 100644 --- a/home/emmatherock/neovim.nix +++ b/home/emmatherock/neovim.nix @@ -87,14 +87,55 @@ enable = true; settings.sources = [ { name = "nvim_lsp"; } + { name = "luasnip"; } { name = "path"; } { name = "buffer"; } ]; + settings.snippet.expand = '' + function(args) + require("luasnip").lsp_expand(args.body) + end + ''; + settings.mapping = { + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + else + fallback() + end + end, { "i", "s" }) + ''; + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, { "i", "s" }) + ''; + }; }; plugins.cmp-nvim-lsp.enable = true; + plugins.cmp_luasnip.enable = true; plugins.cmp-path.enable = true; plugins.cmp-buffer.enable = true; + # --- Snippets --- + plugins.luasnip = { + enable = true; + fromVscode = [ { paths = "${pkgs.vimPlugins.friendly-snippets}"; } ]; + }; + + # --- Pairs and surrounding text --- + plugins.nvim-autopairs.enable = true; + plugins.nvim-surround.enable = true; + # --- Format on save --- plugins.conform-nvim = { enable = true;