From 3d0b82e9c728c9db1bb76d6a8da3fc18ddab3333 Mon Sep 17 00:00:00 2001 From: Julia Lange Date: Wed, 18 Feb 2026 13:12:02 -0800 Subject: [PATCH] merged nvimcmp to app.nix --- hmModules/apps/neovim/app.nix | 40 +++++++++++++ hmModules/apps/neovim/plugin/nvimcmp.nix | 72 ------------------------ 2 files changed, 40 insertions(+), 72 deletions(-) delete mode 100644 hmModules/apps/neovim/plugin/nvimcmp.nix diff --git a/hmModules/apps/neovim/app.nix b/hmModules/apps/neovim/app.nix index 67e46a4..b996294 100644 --- a/hmModules/apps/neovim/app.nix +++ b/hmModules/apps/neovim/app.nix @@ -82,6 +82,46 @@ { name = "path"; } { name = "buffer"; } ] + lib.options luasnip.enable { name = "cmp-luasnip" }; + + mapping = { + "" = "cmp.mapping.complete {}"; + "" = "cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }"; + "" = { + actions = '' + function(fallback) + if cmp.visible() then + cmp.select_next_item() + '' + lib.optionalString luasnip.enable '' + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + '' + '' + else + fallback() + end + end + ''; + modes = [ "i" "s" ]; + }; + "" = { + actions = '' + function(fallback) + if cmp.visible() then + cmp.select_prev_item() + '' + lib.optionalString luasnip.enable '' + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + '' + '' + else + fallback() + end + end + ''; + modes = [ "i" "s" ]; + }; + }; }; telescope.enable = telescope.enable; diff --git a/hmModules/apps/neovim/plugin/nvimcmp.nix b/hmModules/apps/neovim/plugin/nvimcmp.nix deleted file mode 100644 index 82098ef..0000000 --- a/hmModules/apps/neovim/plugin/nvimcmp.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - cfgp = config.neovim.plugins; -in { - config = lib.mkIf (config.neovim.enable && cfgp.nvimcmp.enable) { - programs.neovim.plugins = let - - configText = '' - local cmp = require('cmp') - '' + lib.strings.optionalString cfgp.luasnip.enable '' - local luasnip = require('luasnip') - - require('luasnip.loaders.from_vscode').lazy_load() - luasnip.config.setup {} - '' + '' - - cmp.setup { - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - '' + lib.strings.optionalString cfgp.luasnip.enable '' - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - '' + '' - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - '' + lib.strings.optionalString cfgp.luasnip.enable '' - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - '' + '' - else - fallback() - end - end, { 'i', 's' }), - }, - '' + lib.strings.optionalString cfgp.luasnip.enable '' - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - sources = { - { name = 'luasnip' }, - }, - '' + '' - } - ''; - in with pkgs.vimPlugins; [ - { - plugin = nvim-cmp; - type = "lua"; - config = configText; - } - ]; - }; -}