Skip to content

Commit

Permalink
lib/neovim-plugin: drop config arg
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Sep 2, 2024
1 parent 2a054b0 commit 18b7597
Show file tree
Hide file tree
Showing 101 changed files with 127 additions and 201 deletions.
47 changes: 26 additions & 21 deletions lib/neovim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ with lib;
};

mkNeovimPlugin =
config:
{
name,
maintainers,
Expand Down Expand Up @@ -71,7 +70,32 @@ with lib;
++ (optional deprecateExtraOptions (
mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
))
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings)
++ [
(
{ config, ... }:
{
config =
let
cfg = config.${namespace}.${name};
extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua";
in
mkIf cfg.enable (mkMerge [
{
extraPlugins = (optional installPackage cfg.package) ++ extraPlugins;
inherit extraPackages;
}
(optionalAttrs callSetup {
${extraConfigNamespace} = ''
require('${luaName}')${setup}(${optionalString (cfg ? settings) (helpers.toLuaObject cfg.settings)})
'';
})
(optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })
(extraConfig cfg)
]);
}
)
];

options.${namespace}.${name} =
{
Expand All @@ -87,24 +111,5 @@ with lib;
};
}
// extraOptions;

config =
let
cfg = config.${namespace}.${name};
extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua";
in
mkIf cfg.enable (mkMerge [
{
extraPlugins = (optional installPackage cfg.package) ++ extraPlugins;
inherit extraPackages;
}
(optionalAttrs callSetup {
${extraConfigNamespace} = ''
require('${luaName}')${setup}(${optionalString (cfg ? settings) (helpers.toLuaObject cfg.settings)})
'';
})
(optionalAttrs (isColorscheme && (colorscheme != null)) { colorscheme = mkDefault colorscheme; })
(extraConfig cfg)
]);
};
}
3 changes: 1 addition & 2 deletions plugins/TEMPLATE.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "my-plugin";
originalName = "my-plugin.nvim"; # TODO replace (or remove entirely if it is the same as `name`)
defaultPackage = pkgs.vimPlugins.my-plugin-nvim; # TODO replace
Expand Down
3 changes: 1 addition & 2 deletions plugins/ai/chatgpt.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
helpers.neovim-plugin.mkNeovimPlugin {
name = "chatgpt";
originalName = "ChatGPT.nvim";
defaultPackage = pkgs.vimPlugins.ChatGPT-nvim;
Expand Down
3 changes: 1 addition & 2 deletions plugins/ai/copilot-chat.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
helpers.neovim-plugin.mkNeovimPlugin {
name = "copilot-chat";
originalName = "CopilotChat.nvim";
luaName = "CopilotChat";
Expand Down
3 changes: 1 addition & 2 deletions plugins/bufferlines/barbar.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
lib,
config,
pkgs,
...
}:
Expand Down Expand Up @@ -51,7 +50,7 @@ let
orderByWindowNumber = "OrderByWindowNumber";
};
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "barbar";
originalName = "barbar.nvim";
defaultPackage = pkgs.vimPlugins.barbar-nvim;
Expand Down
3 changes: 1 addition & 2 deletions plugins/bufferlines/bufferline.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts nixvimTypes mkSettingsRenamedOptionModules;
types = nixvimTypes;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "bufferline";
originalName = "bufferline.nvim";
defaultPackage = pkgs.vimPlugins.bufferline-nvim;
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/ayu.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts toLuaObject;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "ayu";
isColorscheme = true;
originalName = "neovim-ayu";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/base16/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
lib,
config,
pkgs,
...
}:
Expand All @@ -11,7 +10,7 @@ let
luaName = "base16-colorscheme";
originalName = "base16.nvim";
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
inherit name luaName originalName;
setup = ".with_config";
defaultPackage = pkgs.vimPlugins.base16-nvim;
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/catppuccin.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption mkNullOrStrLuaFnOr;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "catppuccin";
isColorscheme = true;
defaultPackage = pkgs.vimPlugins.catppuccin-nvim;
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/cyberdream.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "cyberdream";
isColorscheme = true;
originalName = "cyberdream.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/gruvbox.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
lib,
config,
pkgs,
...
}:
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "gruvbox";
isColorscheme = true;
originalName = "gruvbox.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/kanagawa.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "kanagawa";
isColorscheme = true;
originalName = "kanagawa.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/modus.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "modus";
luaName = "modus-themes";
originalName = "modus-themes.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/nightfox.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "nightfox";
isColorscheme = true;
originalName = "nightfox.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/onedark.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
lib,
config,
pkgs,
...
}:
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "onedark";
isColorscheme = true;
originalName = "onedark.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/palette.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "palette";
isColorscheme = true;
originalName = "palette.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/poimandres.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "poimandres";
isColorscheme = true;
originalName = "poimandres.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/rose-pine.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "rose-pine";
isColorscheme = true;
defaultPackage = pkgs.vimPlugins.rose-pine;
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/tokyonight.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
pkgs,
config,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "tokyonight";
isColorscheme = true;
originalName = "tokyonight.nvim";
Expand Down
3 changes: 1 addition & 2 deletions plugins/colorschemes/vscode.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts toLuaObject;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "vscode";
isColorscheme = true;
originalName = "vscode-nvim";
Expand Down
5 changes: 2 additions & 3 deletions plugins/completion/cmp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
lib,
helpers,
pkgs,
config,
...
}@args:
}:
let
cmpOptions = import ./options { inherit lib helpers; };
in
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
helpers.neovim-plugin.mkNeovimPlugin {
name = "cmp";
originalName = "nvim-cmp";
defaultPackage = pkgs.vimPlugins.nvim-cmp;
Expand Down
3 changes: 1 addition & 2 deletions plugins/completion/coq.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
helpers.neovim-plugin.mkNeovimPlugin {
name = "coq-nvim";
originalName = "coq_nvim";
defaultPackage = pkgs.vimPlugins.coq_nvim;
Expand Down
3 changes: 1 addition & 2 deletions plugins/filetrees/yazi.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
types = lib.nixvim.nixvimTypes;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "yazi";
originalName = "yazi.nvim";
defaultPackage = pkgs.vimPlugins.yazi-nvim;
Expand Down
Loading

0 comments on commit 18b7597

Please sign in to comment.