diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index ea911c1..1ac74a6 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -9,18 +9,23 @@ inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; # Get the names of all flake inputs that start with the given prefix. - fromInputs = inputs: prefix: + fromInputs = { + inputs, + prefix, + }: mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs); - pluginsFromInputs = attrNames (fromInputs inputs "plugin-"); - # Get the names of all flake inputs that start with the given prefix. + pluginInputNames = attrNames (fromInputs { + inherit inputs; + prefix = "plugin-"; + }); # You can either use the name of the plugin or a package. pluginType = nullOr ( either package - (enum (pluginsFromInputs ++ ["nvim-treesitter" "flutter-tools-patched" "vim-repeat"])) + (enum (pluginInputNames ++ ["nvim-treesitter" "flutter-tools-patched" "vim-repeat"])) ); pluginsType = listOf pluginType; @@ -47,7 +52,7 @@ }; }; in { - inherit extraPluginType; + inherit extraPluginType fromInputs; pluginsOpt = { description, diff --git a/modules/default.nix b/modules/default.nix index e8083e7..17e8ba1 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,6 +10,7 @@ inputs: { inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.neovimUtils) makeNeovimConfig; inherit (lib.attrsets) recursiveUpdate; + inherit (lib.asserts) assertMsg; extendedLib = import ../lib/stdlib-extended.nix lib inputs; @@ -28,11 +29,11 @@ inputs: { extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; buildPlug = {pname, ...} @ args: - assert lib.asserts.assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter."; + assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter."; buildVimPlugin (args // { version = "master"; - src = getAttr pname inputs; + src = getAttr ("plugin-" + pname) inputs; }); buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);