lib/vim-plugin: drop config arg

Instead, access it via an imported module
This commit is contained in:
Matt Sturgeon 2024-09-01 12:36:31 +01:00
parent 9b0e2ba7e5
commit 2a054b039e
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
45 changed files with 67 additions and 102 deletions

View file

@ -2,7 +2,6 @@
with lib;
{
mkVimPlugin =
config:
{
name,
url ? if defaultPackage != null then defaultPackage.meta.homepage else null,
@ -30,10 +29,6 @@ with lib;
let
namespace = if isColorscheme then "colorschemes" else "plugins";
cfg = config.${namespace}.${name};
globals = cfg.settings or { };
# does this evaluate package?
packageOption =
if defaultPackage == null then
@ -58,6 +53,27 @@ with lib;
'';
};
};
modules = [
(
{ config, ... }:
let
cfg = config.${namespace}.${name};
in
{
config = mkIf cfg.enable (mkMerge [
{
inherit extraPackages;
globals = mapAttrs' (n: 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 ++ optional (defaultPackage != null) cfg.package;
}
(optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })
(extraConfig cfg)
]);
}
)
];
in
{
meta = {
@ -86,17 +102,8 @@ with lib;
++ (optional (deprecateExtraConfig && createSettingsOption) (
mkRenamedOptionModule (basePluginPath ++ [ "extraConfig" ]) settingsPath
))
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings)
++ modules;
config = mkIf cfg.enable (mkMerge [
{
inherit extraPackages;
globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals;
# does this evaluate package? it would not be desired to evaluate package if we use another package.
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
}
(optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })
(extraConfig cfg)
]);
};
}

View file

@ -1,6 +1,5 @@
{
lib,
config,
pkgs,
...
}:
@ -15,7 +14,7 @@ let
] pluginDefault desc;
in
lib.nixvim.vim-plugin.mkVimPlugin config {
lib.nixvim.vim-plugin.mkVimPlugin {
name = "everforest";
isColorscheme = true;
defaultPackage = pkgs.vimPlugins.everforest;

View file

@ -1,10 +1,9 @@
{
lib,
config,
pkgs,
...
}:
lib.nixvim.vim-plugin.mkVimPlugin config {
lib.nixvim.vim-plugin.mkVimPlugin {
name = "melange";
isColorscheme = true;
originalName = "melange-nvim";

View file

@ -1,13 +1,12 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.vim-plugin.mkVimPlugin config {
lib.nixvim.vim-plugin.mkVimPlugin {
name = "nord";
isColorscheme = true;
originalName = "nord.nvim";

View file

@ -1,10 +1,9 @@
{
lib,
config,
pkgs,
...
}:
lib.nixvim.vim-plugin.mkVimPlugin config {
lib.nixvim.vim-plugin.mkVimPlugin {
name = "one";
isColorscheme = true;
originalName = "vim-one";

View file

@ -1,10 +1,9 @@
{
lib,
config,
pkgs,
...
}:
lib.nixvim.vim-plugin.mkVimPlugin config {
lib.nixvim.vim-plugin.mkVimPlugin {
name = "oxocarbon";
isColorscheme = true;
originalName = "oxocarbon.nvim";

View file

@ -1,7 +1,6 @@
{
lib,
helpers,
config,
pkgs,
...
}:
@ -13,7 +12,7 @@
imports ? [ ],
...
}@args:
helpers.vim-plugin.mkVimPlugin config (
helpers.vim-plugin.mkVimPlugin (
builtins.removeAttrs args [
"pluginName"
"sourceName"

View file

@ -1,7 +1,6 @@
{
lib,
helpers,
config,
pkgs,
...
}:
@ -35,7 +34,7 @@ let
};
};
in
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "codeium-vim";
originalName = "codeium.vim";
defaultPackage = pkgs.vimPlugins.codeium-vim;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "copilot-vim";
originalName = "copilot.vim";
defaultPackage = pkgs.vimPlugins.copilot-vim;

View file

@ -1,10 +1,9 @@
{
config,
helpers,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "committia";
originalName = "committia.vim";
defaultPackage = pkgs.vimPlugins.committia-vim;

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "fugitive";
originalName = "vim-fugitive";
defaultPackage = pkgs.vimPlugins.vim-fugitive;

View file

@ -1,14 +1,13 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
# We use `mkVimPlugin` to avoid having a `settings` option.
# Indeed, this plugin is not configurable in the common sense (no `setup` function).
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "gitignore";
originalName = "gitignore.nvim";
defaultPackage = pkgs.vimPlugins.gitignore-nvim;

View file

@ -1,12 +1,11 @@
{
config,
lib,
helpers,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "lazygit";
originalName = "lazygit.nvim";
defaultPackage = pkgs.vimPlugins.lazygit-nvim;

View file

@ -1,12 +1,11 @@
{
config,
lib,
helpers,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "godot";
originalName = "vim-godot";
defaultPackage = pkgs.vimPlugins.vim-godot;

View file

@ -6,7 +6,7 @@
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "haskell-scope-highlighting";
originalName = "haskell-scope-highlighting.nvim";
defaultPackage = pkgs.vimPlugins.haskell-scope-highlighting-nvim;

View file

@ -1,7 +1,6 @@
{
lib,
helpers,
config,
pkgs,
...
}:
@ -37,7 +36,7 @@ let
};
in
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "julia-cell";
originalName = "vim-julia-cell";
defaultPackage = pkgs.vimPlugins.vim-julia-cell;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "ledger";
originalName = "vim-ledger";
defaultPackage = pkgs.vimPlugins.vim-ledger;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "markdown-preview";
originalName = "markdown-preview.nvim";
defaultPackage = pkgs.vimPlugins.markdown-preview-nvim;

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "nix";
originalName = "vim-nix";
defaultPackage = pkgs.vimPlugins.vim-nix;

View file

@ -1,11 +1,10 @@
{
lib,
helpers,
config,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "parinfer-rust";
defaultPackage = pkgs.vimPlugins.parinfer-rust;
globalPrefix = "parinfer_";

View file

@ -1,11 +1,10 @@
{
helpers,
config,
pkgs,
lib,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "tagbar";
defaultPackage = pkgs.vimPlugins.tagbar;
globalPrefix = "tagbar_";

View file

@ -1,14 +1,13 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
# This plugin has no configuration, so we use `mkVimPlugin` without the `globalPrefix` argument to
# avoid the creation of the `settings` option.
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "texpresso";
originalName = "texpresso.vim";
defaultPackage = pkgs.vimPlugins.texpresso-vim;

View file

@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "typst-vim";
originalName = "typst.vim";
defaultPackage = pkgs.vimPlugins.typst-vim;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "vim-slime";
defaultPackage = pkgs.vimPlugins.vim-slime;
globalPrefix = "slime_";

View file

@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "vimtex";
defaultPackage = pkgs.vimPlugins.vimtex;
globalPrefix = "vimtex_";

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "zig";
originalName = "zig.vim";
defaultPackage = pkgs.vimPlugins.zig-vim;

View file

@ -6,7 +6,7 @@
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "schemastore";
originalName = "SchemaStore.nvim";
defaultPackage = pkgs.vimPlugins.SchemaStore-nvim;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "airline";
originalName = "vim-airline";
defaultPackage = pkgs.vimPlugins.vim-airline;

View file

@ -1,12 +1,11 @@
{
config,
helpers,
pkgs,
lib,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "bufdelete";
originalName = "bufdelete.nvim";
defaultPackage = pkgs.vimPlugins.bufdelete-nvim;

View file

@ -1,12 +1,11 @@
{
config,
helpers,
pkgs,
lib,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "direnv";
originalName = "direnv.vim";
defaultPackage = pkgs.vimPlugins.direnv-vim;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "emmet";
originalName = "emmet-vim";
defaultPackage = pkgs.vimPlugins.emmet-vim;

View file

@ -1,11 +1,10 @@
{
config,
lib,
pkgs,
helpers,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "endwise";
originalName = "vim-endwise";
defaultPackage = pkgs.vimPlugins.vim-endwise;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with helpers.vim-plugin;
with lib;
mkVimPlugin config {
mkVimPlugin {
name = "goyo";
originalName = "goyo.vim";
defaultPackage = pkgs.vimPlugins.goyo-vim;

View file

@ -1,14 +1,13 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
# This plugin is only configured through keymaps, so we use `mkVimPlugin` without the
# `globalPrefix` argument to avoid the creation of the `settings` option.
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "improved-search";
originalName = "improved-search.nvim";
defaultPackage = pkgs.vimPlugins.improved-search-nvim;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "instant";
originalName = "instant.nvim";
defaultPackage = pkgs.vimPlugins.instant-nvim;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "magma-nvim";
originalName = "magma-nvim";
defaultPackage = pkgs.vimPlugins.magma-nvim-goose;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "molten";
originalName = "molten-nvim";
defaultPackage = pkgs.vimPlugins.molten-nvim;

View file

@ -1,12 +1,11 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "sandwich";
originalName = "vim-sandwich";
defaultPackage = pkgs.vimPlugins.vim-sandwich;

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "sleuth";
originalName = "vim-sleuth";
defaultPackage = pkgs.vimPlugins.vim-sleuth;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "startify";
originalName = "vim-startify";
defaultPackage = pkgs.vimPlugins.vim-startify;

View file

@ -1,11 +1,10 @@
{
config,
lib,
helpers,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "surround";
originalName = "surround.vim";
defaultPackage = pkgs.vimPlugins.vim-surround;

View file

@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "tmux-navigator";
originalName = "vim-tmux-navigator";
defaultPackage = pkgs.vimPlugins.vim-tmux-navigator;

View file

@ -1,13 +1,12 @@
{
lib,
config,
helpers,
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
mkVimPlugin {
name = "undotree";
defaultPackage = pkgs.vimPlugins.undotree;
globalPrefix = "undotree_";

View file

@ -1,10 +1,9 @@
{
config,
helpers,
pkgs,
...
}:
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "vim-css-color";
defaultPackage = pkgs.vimPlugins.vim-css-color;

View file

@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
helpers.vim-plugin.mkVimPlugin {
name = "wakatime";
originalName = "vim-wakatime";
defaultPackage = pkgs.vimPlugins.vim-wakatime;