mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
helpers/neovim-plugin/mkNeovimPlugin: add a colorscheme argument and factor out logic
This commit is contained in:
parent
9f9d9ac0b7
commit
3c9a4b67ae
3 changed files with 22 additions and 9 deletions
|
@ -32,7 +32,7 @@ with lib; rec {
|
||||||
|
|
||||||
mkNeovimPlugin = config: {
|
mkNeovimPlugin = config: {
|
||||||
name,
|
name,
|
||||||
namespace ? "plugins",
|
colorscheme ? false,
|
||||||
maintainers,
|
maintainers,
|
||||||
url ? defaultPackage.meta.homepage,
|
url ? defaultPackage.meta.homepage,
|
||||||
imports ? [],
|
imports ? [],
|
||||||
|
@ -51,7 +51,12 @@ with lib; rec {
|
||||||
extraPlugins ? [],
|
extraPlugins ? [],
|
||||||
extraPackages ? [],
|
extraPackages ? [],
|
||||||
callSetup ? true,
|
callSetup ? true,
|
||||||
}: {
|
}: let
|
||||||
|
namespace =
|
||||||
|
if colorscheme
|
||||||
|
then "colorschemes"
|
||||||
|
else "plugins";
|
||||||
|
in {
|
||||||
meta = {
|
meta = {
|
||||||
inherit maintainers;
|
inherit maintainers;
|
||||||
nixvimInfo = {
|
nixvimInfo = {
|
||||||
|
@ -108,6 +113,10 @@ with lib; rec {
|
||||||
|
|
||||||
config = let
|
config = let
|
||||||
cfg = config.${namespace}.${name};
|
cfg = config.${namespace}.${name};
|
||||||
|
extraConfigNamespace =
|
||||||
|
if colorscheme
|
||||||
|
then "extraConfigLuaPre"
|
||||||
|
else "extraConfigLua";
|
||||||
in
|
in
|
||||||
mkIf cfg.enable (
|
mkIf cfg.enable (
|
||||||
mkMerge [
|
mkMerge [
|
||||||
|
@ -115,10 +124,15 @@ with lib; rec {
|
||||||
extraPlugins = [cfg.package] ++ extraPlugins;
|
extraPlugins = [cfg.package] ++ extraPlugins;
|
||||||
inherit extraPackages;
|
inherit extraPackages;
|
||||||
|
|
||||||
extraConfigLua = optionalString callSetup ''
|
${extraConfigNamespace} = optionalString callSetup ''
|
||||||
require('${luaName}').setup(${toLuaObject cfg.settings})
|
require('${luaName}').setup(${toLuaObject cfg.settings})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
(optionalAttrs colorscheme {
|
||||||
|
# We use `mkDefault` here to let individual plugins override this option.
|
||||||
|
# For instance, setting it to `null` a specific way of setting the coloscheme.
|
||||||
|
colorscheme = lib.mkDefault name;
|
||||||
|
})
|
||||||
(extraConfig cfg)
|
(extraConfig cfg)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
with lib;
|
with lib;
|
||||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
name = "ayu";
|
name = "ayu";
|
||||||
namespace = "colorschemes";
|
colorscheme = true;
|
||||||
originalName = "neovim-ayu";
|
originalName = "neovim-ayu";
|
||||||
defaultPackage = pkgs.vimPlugins.neovim-ayu;
|
defaultPackage = pkgs.vimPlugins.neovim-ayu;
|
||||||
callSetup = false;
|
callSetup = false;
|
||||||
|
@ -42,6 +42,9 @@ with lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
|
# The colorscheme option is set by the `setup` function.
|
||||||
|
colorscheme = null;
|
||||||
|
|
||||||
extraConfigLuaPre = ''
|
extraConfigLuaPre = ''
|
||||||
local ayu = require("ayu")
|
local ayu = require("ayu")
|
||||||
ayu.setup(${helpers.toLuaObject cfg.settings})
|
ayu.setup(${helpers.toLuaObject cfg.settings})
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
}:
|
}:
|
||||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
name = "gruvbox";
|
name = "gruvbox";
|
||||||
namespace = "colorschemes";
|
colorscheme = true;
|
||||||
originalName = "gruvbox.nvim";
|
originalName = "gruvbox.nvim";
|
||||||
defaultPackage = pkgs.vimPlugins.gruvbox-nvim;
|
defaultPackage = pkgs.vimPlugins.gruvbox-nvim;
|
||||||
|
|
||||||
|
@ -57,8 +57,4 @@ helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
bright_purple = "#fb4934";
|
bright_purple = "#fb4934";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = cfg: {
|
|
||||||
colorscheme = "gruvbox";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue