mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
helpers: refactor mk[Neo]vimPlugin for colorschemes handling
This commit is contained in:
parent
61ee0552c9
commit
cf7102c6d2
5 changed files with 18 additions and 19 deletions
|
@ -32,13 +32,15 @@ with lib; rec {
|
||||||
|
|
||||||
mkNeovimPlugin = config: {
|
mkNeovimPlugin = config: {
|
||||||
name,
|
name,
|
||||||
colorscheme ? false,
|
|
||||||
maintainers,
|
maintainers,
|
||||||
url ? defaultPackage.meta.homepage,
|
url ? defaultPackage.meta.homepage,
|
||||||
imports ? [],
|
imports ? [],
|
||||||
# deprecations
|
# deprecations
|
||||||
deprecateExtraOptions ? false,
|
deprecateExtraOptions ? false,
|
||||||
optionsRenamedToSettings ? [],
|
optionsRenamedToSettings ? [],
|
||||||
|
# colorscheme
|
||||||
|
isColorscheme ? false,
|
||||||
|
colorscheme ? name,
|
||||||
# options
|
# options
|
||||||
originalName ? name,
|
originalName ? name,
|
||||||
defaultPackage,
|
defaultPackage,
|
||||||
|
@ -53,7 +55,7 @@ with lib; rec {
|
||||||
callSetup ? true,
|
callSetup ? true,
|
||||||
}: let
|
}: let
|
||||||
namespace =
|
namespace =
|
||||||
if colorscheme
|
if isColorscheme
|
||||||
then "colorschemes"
|
then "colorschemes"
|
||||||
else "plugins";
|
else "plugins";
|
||||||
in {
|
in {
|
||||||
|
@ -114,7 +116,7 @@ with lib; rec {
|
||||||
config = let
|
config = let
|
||||||
cfg = config.${namespace}.${name};
|
cfg = config.${namespace}.${name};
|
||||||
extraConfigNamespace =
|
extraConfigNamespace =
|
||||||
if colorscheme
|
if isColorscheme
|
||||||
then "extraConfigLuaPre"
|
then "extraConfigLuaPre"
|
||||||
else "extraConfigLua";
|
else "extraConfigLua";
|
||||||
in
|
in
|
||||||
|
@ -128,10 +130,8 @@ with lib; rec {
|
||||||
require('${luaName}').setup(${toLuaObject cfg.settings})
|
require('${luaName}').setup(${toLuaObject cfg.settings})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
(optionalAttrs colorscheme {
|
(optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||||
# We use `mkDefault` here to let individual plugins override this option.
|
inherit colorscheme;
|
||||||
# For instance, setting it to `null` a specific way of setting the coloscheme.
|
|
||||||
colorscheme = lib.mkDefault name;
|
|
||||||
})
|
})
|
||||||
(extraConfig cfg)
|
(extraConfig cfg)
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
with lib; {
|
with lib; {
|
||||||
mkVimPlugin = config: {
|
mkVimPlugin = config: {
|
||||||
name,
|
name,
|
||||||
colorscheme ? false,
|
|
||||||
url ?
|
url ?
|
||||||
if defaultPackage != null
|
if defaultPackage != null
|
||||||
then defaultPackage.meta.homepage
|
then defaultPackage.meta.homepage
|
||||||
|
@ -16,6 +15,9 @@ with lib; {
|
||||||
# deprecations
|
# deprecations
|
||||||
deprecateExtraConfig ? false,
|
deprecateExtraConfig ? false,
|
||||||
optionsRenamedToSettings ? [],
|
optionsRenamedToSettings ? [],
|
||||||
|
# colorscheme
|
||||||
|
isColorscheme ? false,
|
||||||
|
colorscheme ? name,
|
||||||
# options
|
# options
|
||||||
originalName ? name,
|
originalName ? name,
|
||||||
defaultPackage ? null,
|
defaultPackage ? null,
|
||||||
|
@ -30,7 +32,7 @@ with lib; {
|
||||||
extraPackages ? [],
|
extraPackages ? [],
|
||||||
}: let
|
}: let
|
||||||
namespace =
|
namespace =
|
||||||
if colorscheme
|
if isColorscheme
|
||||||
then "colorschemes"
|
then "colorschemes"
|
||||||
else "plugins";
|
else "plugins";
|
||||||
|
|
||||||
|
@ -127,10 +129,8 @@ with lib; {
|
||||||
# does this evaluate package? it would not be desired to evaluate package if we use another package.
|
# does this evaluate package? it would not be desired to evaluate package if we use another package.
|
||||||
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
|
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
|
||||||
}
|
}
|
||||||
(optionalAttrs colorscheme {
|
(optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||||
# We use `mkDefault` here to let individual plugins override this option.
|
inherit colorscheme;
|
||||||
# For instance, setting it to `null` a specific way of setting the coloscheme.
|
|
||||||
colorscheme = lib.mkDefault name;
|
|
||||||
})
|
})
|
||||||
(extraConfig cfg)
|
(extraConfig cfg)
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
with lib;
|
with lib;
|
||||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
name = "ayu";
|
name = "ayu";
|
||||||
colorscheme = true;
|
isColorscheme = true;
|
||||||
originalName = "neovim-ayu";
|
originalName = "neovim-ayu";
|
||||||
defaultPackage = pkgs.vimPlugins.neovim-ayu;
|
defaultPackage = pkgs.vimPlugins.neovim-ayu;
|
||||||
|
# The colorscheme option is set by the `setup` function.
|
||||||
|
colorscheme = null;
|
||||||
callSetup = false;
|
callSetup = false;
|
||||||
|
|
||||||
maintainers = [maintainers.GaetanLepage];
|
maintainers = [maintainers.GaetanLepage];
|
||||||
|
@ -42,9 +44,6 @@ 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";
|
||||||
colorscheme = true;
|
isColorscheme = true;
|
||||||
originalName = "gruvbox.nvim";
|
originalName = "gruvbox.nvim";
|
||||||
defaultPackage = pkgs.vimPlugins.gruvbox-nvim;
|
defaultPackage = pkgs.vimPlugins.gruvbox-nvim;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
}:
|
}:
|
||||||
helpers.vim-plugin.mkVimPlugin config {
|
helpers.vim-plugin.mkVimPlugin config {
|
||||||
name = "nord";
|
name = "nord";
|
||||||
colorscheme = true;
|
isColorscheme = true;
|
||||||
originalName = "nord.nvim";
|
originalName = "nord.nvim";
|
||||||
defaultPackage = pkgs.vimPlugins.nord-nvim;
|
defaultPackage = pkgs.vimPlugins.nord-nvim;
|
||||||
globalPrefix = "nord_";
|
globalPrefix = "nord_";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue