mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 09:18:38 +02:00
lib/{vim,neovim}-plugin: installPackage
-> packageDecorator
Replace `mkNeovimPlugin`'s `installPackage` parameter with a new internal module option: `packageDecorator`. The option is a function that applies some transformation to `cfg.package`'s value before it is installed.
This commit is contained in:
parent
1d78aee791
commit
de99f2938f
3 changed files with 30 additions and 10 deletions
|
@ -50,7 +50,6 @@
|
||||||
extraPlugins ? [ ],
|
extraPlugins ? [ ],
|
||||||
extraPackages ? [ ],
|
extraPackages ? [ ],
|
||||||
callSetup ? true,
|
callSetup ? true,
|
||||||
installPackage ? true,
|
|
||||||
}@args:
|
}@args:
|
||||||
let
|
let
|
||||||
namespace = if isColorscheme then "colorschemes" else "plugins";
|
namespace = if isColorscheme then "colorschemes" else "plugins";
|
||||||
|
@ -104,6 +103,16 @@
|
||||||
package
|
package
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
packageDecorator = lib.mkOption {
|
||||||
|
type = lib.types.functionTo lib.types.package;
|
||||||
|
default = lib.id;
|
||||||
|
defaultText = lib.literalExpression "x: x";
|
||||||
|
description = ''
|
||||||
|
Additional transformations to apply to the final installed package.
|
||||||
|
The result of these transformations is **not** visible in the `package` option's value.
|
||||||
|
'';
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs hasSettings {
|
// lib.optionalAttrs hasSettings {
|
||||||
settings = lib.nixvim.mkSettingsOption {
|
settings = lib.nixvim.mkSettingsOption {
|
||||||
|
@ -129,8 +138,10 @@
|
||||||
lib.mkMerge (
|
lib.mkMerge (
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
extraPlugins = (lib.optional installPackage cfg.package) ++ extraPlugins;
|
|
||||||
inherit extraPackages;
|
inherit extraPackages;
|
||||||
|
extraPlugins = extraPlugins ++ [
|
||||||
|
(cfg.packageDecorator cfg.package)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||||
colorscheme = lib.mkDefault colorscheme;
|
colorscheme = lib.mkDefault colorscheme;
|
||||||
|
|
|
@ -91,15 +91,26 @@
|
||||||
package
|
package
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
packageDecorator = lib.mkOption {
|
||||||
|
type = lib.types.functionTo lib.types.package;
|
||||||
|
default = lib.id;
|
||||||
|
defaultText = lib.literalExpression "x: x";
|
||||||
|
description = ''
|
||||||
|
Additional transformations to apply to the final installed package.
|
||||||
|
The result of these transformations is **not** visible in the `package` option's value.
|
||||||
|
'';
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
} // settingsOption // extraOptions;
|
} // settingsOption // extraOptions;
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (
|
config = lib.mkIf cfg.enable (
|
||||||
lib.mkMerge [
|
lib.mkMerge [
|
||||||
{
|
{
|
||||||
inherit extraPackages;
|
inherit extraPackages;
|
||||||
|
extraPlugins = extraPlugins ++ [
|
||||||
|
(cfg.packageDecorator cfg.package)
|
||||||
|
];
|
||||||
globals = lib.mapAttrs' (n: lib.nameValuePair (globalPrefix + n)) (cfg.settings or { });
|
globals = lib.mapAttrs' (n: lib.nameValuePair (globalPrefix + n)) (cfg.settings or { });
|
||||||
# does this evaluate package? it would not be desired to evaluate package if we use another package.
|
|
||||||
extraPlugins = extraPlugins ++ lib.optional (cfg.package != null) cfg.package;
|
|
||||||
}
|
}
|
||||||
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||||
colorscheme = lib.mkDefault colorscheme;
|
colorscheme = lib.mkDefault colorscheme;
|
||||||
|
|
|
@ -430,8 +430,6 @@ helpers.neovim-plugin.mkNeovimPlugin {
|
||||||
|
|
||||||
# NOTE: We call setup manually below.
|
# NOTE: We call setup manually below.
|
||||||
callSetup = false;
|
callSetup = false;
|
||||||
# NOTE: We install cfg.package manually so we can install grammars using it.
|
|
||||||
installPackage = false;
|
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
plugins.treesitter.luaConfig.content =
|
plugins.treesitter.luaConfig.content =
|
||||||
|
@ -455,10 +453,10 @@ helpers.neovim-plugin.mkNeovimPlugin {
|
||||||
|
|
||||||
extraFiles = mkIf cfg.nixvimInjections { "queries/nix/injections.scm".source = ./injections.scm; };
|
extraFiles = mkIf cfg.nixvimInjections { "queries/nix/injections.scm".source = ./injections.scm; };
|
||||||
|
|
||||||
extraPlugins = mkIf (cfg.package != null) [
|
# Install the grammar packages if enabled
|
||||||
(mkIf cfg.nixGrammars (cfg.package.withPlugins (_: cfg.grammarPackages)))
|
plugins.treesitter.packageDecorator = lib.mkIf cfg.nixGrammars (
|
||||||
(mkIf (!cfg.nixGrammars) cfg.package)
|
pkg: pkg.withPlugins (_: cfg.grammarPackages)
|
||||||
];
|
);
|
||||||
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
cfg.gccPackage
|
cfg.gccPackage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue