From 2b3b0d0c4630f3483b247b67fddfaca8138ded87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Sat, 13 Jun 2026 13:14:15 +0200 Subject: [PATCH] wrapper/environment: add `vim.appName` corresponding to `NVIM_APPNAME` --- modules/wrapper/build/config.nix | 82 ++++++++++++++----------- modules/wrapper/environment/options.nix | 29 ++++++++- 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index ba25552c..58f81254 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -4,17 +4,25 @@ pkgs, lib, ... -}: let +}: +let inherit (pkgs) vimPlugins; inherit (lib.trivial) flip; - inherit (builtins) filter isString hasAttr getAttr; + inherit (builtins) + filter + isString + hasAttr + getAttr + ; getPin = flip getAttr (inputs.mnw.lib.npinsToPluginsAttrs pkgs ../../../npins/sources.json); # Build a Vim plugin with the given name and arguments. - buildPlug = attrs: let - pin = getPin attrs.pname; - in + buildPlug = + attrs: + let + pin = getPin attrs.pname; + in pkgs.vimUtils.buildVimPlugin ( { version = pin.revision or "dirty"; @@ -24,16 +32,14 @@ ); # Build a given Treesitter grammar. - buildTreesitterPlug = grammars: - vimPlugins.nvim-treesitter.withPlugins ( - _: builtins.filter (g: g != null) grammars - ); + buildTreesitterPlug = + grammars: vimPlugins.nvim-treesitter.withPlugins (_: builtins.filter (g: g != null) grammars); pluginBuilders = { nvim-treesitter = buildTreesitterPlug config.vim.treesitter.grammars; flutter-tools-patched = buildPlug { pname = "flutter-tools-nvim"; - patches = [./patches/flutter-tools.patch]; + patches = [ ./patches/flutter-tools.patch ]; # Disable failing require check hook checks doCheck = false; @@ -60,27 +66,28 @@ inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp avante-nvim; }; - buildConfigPlugins = plugins: - map (plug: - if (isString plug) - then - if hasAttr plug config.vim.pluginOverrides - then - (let - plugin = config.vim.pluginOverrides.${plug}; - in - if (lib.isType "flake" plugin) - then plugin // {name = plug;} - else plugin) - else pluginBuilders.${plug} or (getPin plug) - else plug) ( - filter (f: f != null) plugins - ); + buildConfigPlugins = + plugins: + map ( + plug: + if (isString plug) then + if hasAttr plug config.vim.pluginOverrides then + ( + let + plugin = config.vim.pluginOverrides.${plug}; + in + if (lib.isType "flake" plugin) then plugin // { name = plug; } else plugin + ) + else + pluginBuilders.${plug} or (getPin plug) + else + plug + ) (filter (f: f != null) plugins); # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to # generate a wrapped Neovim package. - neovim-wrapped = inputs.mnw.lib.wrap {inherit pkgs;} { - appName = "nvf"; + neovim-wrapped = inputs.mnw.lib.wrap { inherit pkgs; } { + appName = config.vim.appName; neovim = config.vim.package; initLua = config.vim.builtLuaConfigRC; luaFiles = config.vim.extraLuaFiles; @@ -97,7 +104,7 @@ nodeJs.enable = config.vim.withNodeJs; python3 = { enable = config.vim.withPython3; - extraPackages = ps: (map (flip builtins.getAttr ps) config.vim.python3Packages) ++ [ps.pynvim]; + extraPackages = ps: (map (flip builtins.getAttr ps) config.vim.python3Packages) ++ [ ps.pynvim ]; }; }; @@ -121,7 +128,11 @@ # or module consumption. neovim = pkgs.symlinkJoin { name = "nvf-with-helpers"; - paths = [neovim-wrapped printConfig printConfigPath]; + paths = [ + neovim-wrapped + printConfig + printConfigPath + ]; postBuild = "echo Helpers added"; passthru = { @@ -142,13 +153,12 @@ mnwConfigDir = neovim-wrapped.passthru.configDir; }; - meta = - neovim-wrapped.meta - // { - description = "Wrapped Neovim package with helper scripts to print the config (path)"; - }; + meta = neovim-wrapped.meta // { + description = "Wrapped Neovim package with helper scripts to print the config (path)"; + }; }; -in { +in +{ config.vim.build = { finalPackage = neovim; }; diff --git a/modules/wrapper/environment/options.nix b/modules/wrapper/environment/options.nix index fdc07053..58c84ac6 100644 --- a/modules/wrapper/environment/options.nix +++ b/modules/wrapper/environment/options.nix @@ -3,11 +3,34 @@ lib, ... }: let - inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; - inherit (lib.types) package bool str listOf attrsOf; + inherit + (lib.options) + mkOption + mkEnableOption + literalMD + literalExpression + ; + inherit + (lib.types) + package + bool + str + listOf + attrsOf + ; inherit (lib.nvim.types) pluginsOpt extraPluginType; in { options.vim = { + appName = mkOption { + type = str; + default = "nvf"; + description = '' + The neovim application name corresponding to the + `NVIM_APPNAME` + [environment variable](https://neovim.io/doc/user/starting/#_nvim_appname). + ''; + }; + package = mkOption { type = package; default = pkgs.neovim-unwrapped; @@ -99,7 +122,7 @@ in { extraPackages = mkOption { type = listOf package; default = []; - example = ''[pkgs.fzf pkgs.ripgrep]''; + example = "[pkgs.fzf pkgs.ripgrep]"; description = '' List of additional packages to make available to the Neovim wrapper.