mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 13:45:58 +01:00
modules: add prefix to plugin builder
This commit is contained in:
parent
859b03dfde
commit
88cf62fbc8
2 changed files with 13 additions and 7 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue