Skip to content

Commit

Permalink
lib/plugins: call sub-components with relevant args
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Dec 22, 2024
1 parent 690fc89 commit 787844c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
13 changes: 7 additions & 6 deletions lib/plugins/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
call,
lib,
}:
{ lib }:
let
self = lib.nixvim.plugins;
call = lib.callPackageWith (self // { inherit call lib self; });
in
{
utils = call ./utils.nix { };
neovim = call ./neovim.nix { };
vim = call ./vim.nix { };

# Aliases
inherit (lib.nixvim.plugins.neovim) mkNeovimPlugin;
inherit (lib.nixvim.plugins.vim) mkVimPlugin;
inherit (self.neovim) mkNeovimPlugin;
inherit (self.vim) mkVimPlugin;
}
11 changes: 7 additions & 4 deletions lib/plugins/mk-neovim-plugin.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ lib }:
{
lib,
utils,
}:
{
name,
maintainers,
Expand Down Expand Up @@ -56,7 +59,7 @@ let
})
'';

luaConfigAtLocation = lib.nixvim.plugins.utils.mkConfigAt configLocation cfg.luaConfig.content;
luaConfigAtLocation = utils.mkConfigAt configLocation cfg.luaConfig.content;
in
{
meta = {
Expand Down Expand Up @@ -105,7 +108,7 @@ let

# Apply any additional configuration added to `extraConfig`
(lib.optionalAttrs (args ? extraConfig) (
lib.nixvim.plugins.utils.applyExtraConfig {
utils.applyExtraConfig {
inherit extraConfig cfg opts;
}
))
Expand Down Expand Up @@ -162,7 +165,7 @@ in
imports
++ [
module
(lib.nixvim.plugins.utils.mkPluginPackageModule { inherit loc packPathName package; })
(utils.mkPluginPackageModule { inherit loc packPathName package; })
]
++ lib.optional deprecateExtraOptions (
lib.mkRenamedOptionModule (loc ++ [ "extraOptions" ]) settingsPath
Expand Down
12 changes: 5 additions & 7 deletions lib/plugins/mk-vim-plugin.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{ lib }:
let
inherit (lib.nixvim.plugins.vim)
mkSettingsOption
;
in
{
lib,
self,
}:
{
name,
url ? throw "default",
Expand Down Expand Up @@ -43,7 +41,7 @@ let
createSettingsOption = lib.isString globalPrefix && globalPrefix != "";

settingsOption = lib.optionalAttrs createSettingsOption {
settings = mkSettingsOption {
settings = self.vim.mkSettingsOption {
options = settingsOptions;
example = settingsExample;
inherit name globalPrefix;
Expand Down
8 changes: 2 additions & 6 deletions lib/plugins/vim.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
call,
lib,
self,
}:
let
inherit (lib.nixvim.plugins.vim)
mkSettingsOptionDescription
;
in
{
mkVimPlugin = call ./mk-vim-plugin.nix { };

Expand All @@ -31,6 +27,6 @@ in
}:
lib.nixvim.mkSettingsOption {
inherit options example;
description = mkSettingsOptionDescription { inherit name globalPrefix; };
description = self.vim.mkSettingsOptionDescription { inherit name globalPrefix; };
};
}

0 comments on commit 787844c

Please sign in to comment.