From 2f4291af950f6edbcf2d80610c27380e5112f426 Mon Sep 17 00:00:00 2001 From: "Matthieu C." <886074+teto@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:14:27 +0200 Subject: [PATCH] neovim: expose vimPackage it is relatively cumbersome to generate the vim package from the list of plugins so expose it so users can generate their own packpathdirs for an unwrapped neovim. I've tested this change with an upcoming home-manager change that makes neovim configuration more standard in the home-manager context --- pkgs/applications/editors/neovim/utils.nix | 17 ++++++++++++++++- pkgs/applications/editors/neovim/wrapper.nix | 8 ++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 5f63f2e60df8..4eeb1701a5d3 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -27,7 +27,22 @@ let map (x: defaultPlugin // (if (x ? plugin) then x else { plugin = x; })) plugins; - /* accepts a list of normalized plugins and convert themn + /** + accepts a list of normalized plugins and convert them into a vim package + + # Type + + ``` + normalizedPluginsToVimPackage :: [AttrSet] -> AttrSet + ``` + + # Examples + :::{.example} + + ```nix + normalizedPluginsToVimPackage [ { plugin = vim-fugitive; optional = false'} ] + => { start = [ vim-fugitive ]; opt = []; } + ::: */ normalizedPluginsToVimPackage = normalizedPlugins: let diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 164146814262..60049e184ade 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -80,10 +80,11 @@ let # we call vimrcContent without 'packages' to avoid the init.vim generation neovimRcContent' = vimUtils.vimrcContent { beforePlugins = ""; - customRC = lib.concatStringsSep "\n" (pluginRC ++ [neovimRcContent]); + customRC = lib.concatStringsSep "\n" (pluginRC ++ lib.optional (neovimRcContent != null) neovimRcContent); packages = null; }; + packpathDirs.myNeovimPackages = myVimPackage; finalPackdir = neovimUtils.packDir packpathDirs; rcContent = '' @@ -103,7 +104,6 @@ let ++ (extraPython3Packages ps) ++ (lib.concatMap (f: f ps) pluginPython3Packages)); - packpathDirs.myNeovimPackages = myVimPackage; wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs; @@ -240,6 +240,10 @@ let preferLocalBuild = true; nativeBuildInputs = [ makeWrapper lndir ]; + + # A Vim "package", see ':h packages' + vimPackage = myVimPackage; + passthru = { inherit providerLuaRc packpathDirs; unwrapped = neovim-unwrapped;