misc: refactor imports, prefer adding helpers to args rather than importing it

This commit is contained in:
Gaetan Lepage 2023-11-06 15:04:08 +01:00 committed by Gaétan Lepage
parent 541b694873
commit b6724702b4
160 changed files with 697 additions and 736 deletions

View file

@ -1,14 +1,13 @@
{
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.alpha;
helpers = import ../helpers.nix {inherit lib;};
sectionType = types.enum ["group" "padding" "text"];
mkAlphaSectionOption = type:
@ -85,71 +84,70 @@ in {
default = true;
};
layout = with helpers;
mkOption {
default = [
{
type = "padding";
val = 2;
}
{
type = "text";
val = [
" "
" "
" "
" "
" "
" "
];
opts = {
position = "center";
hl = "Type";
};
}
{
type = "padding";
val = 2;
}
{
type = "group";
val = [
{
shortcut = "e";
desc = " New file";
command = "<CMD>ene <CR>";
}
{
shortcut = "SPC q";
desc = " Quit Neovim";
command = ":qa<CR>";
}
];
}
{
type = "padding";
val = 2;
}
{
type = "text";
val = "Inspiring quote here.";
opts = {
position = "center";
hl = "Keyword";
};
}
];
description = "List of sections to layout for the dashboard";
type = types.listOf (mkAlphaSectionOption sectionType);
};
layout = mkOption {
default = [
{
type = "padding";
val = 2;
}
{
type = "text";
val = [
" "
" "
" "
" "
" "
" "
];
opts = {
position = "center";
hl = "Type";
};
}
{
type = "padding";
val = 2;
}
{
type = "group";
val = [
{
shortcut = "e";
desc = " New file";
command = "<CMD>ene <CR>";
}
{
shortcut = "SPC q";
desc = " Quit Neovim";
command = ":qa<CR>";
}
];
}
{
type = "padding";
val = 2;
}
{
type = "text";
val = "Inspiring quote here.";
opts = {
position = "center";
hl = "Keyword";
};
}
];
description = "List of sections to layout for the dashboard";
type = types.listOf (mkAlphaSectionOption sectionType);
};
};
};
config = with helpers; let
config = let
processButton = button: let
stringifyButton = button: ''button("${button.shortcut}", "${button.desc}", "${button.command}")'';
in
mkRaw (stringifyButton button);
helpers.mkRaw (stringifyButton button);
processButtons = attrset:
if attrset.type == "group"
@ -203,7 +201,7 @@ in {
end
local config = {
layout = ${toLuaObject options.layout},
layout = ${helpers.toLuaObject options.layout},
opts = {
margin = 5,
},

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.auto-save;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.auto-save =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.auto-session;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.auto-session =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.better-escape;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.better-escape =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.comment-nvim;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.comment-nvim = {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.commentary;
helpers = import ../helpers.nix {inherit lib;};
in {
# TODO Add support for aditional filetypes. This requires autocommands!

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.conjure;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.conjure = {
enable = mkEnableOption "Conjure";

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.coverage;
helpers = import ../helpers.nix {inherit lib;};
keymapsDef = {
coverage = {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.cursorline;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.cursorline =
helpers.extraOptionsOptions

View file

@ -1,13 +1,12 @@
{
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.dashboard;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.dashboard = {

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.easyescape;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.easyescape = {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.flash;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.flash = let
configOpts = {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.floaterm;
helpers = import ../helpers.nix {inherit lib;};
settings = {
shell = {

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.hardtime;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.hardtime =

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.harpoon;
helpers = import ../helpers.nix {inherit lib;};
projectConfigModule = types.submodule {
options = {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.hmts;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.hmts =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.illuminate;
helpers = import ../helpers.nix {inherit lib;};
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);

View file

@ -1,11 +1,11 @@
{
lib,
pkgs,
helpers,
config,
pkgs,
...
} @ args:
}:
with lib; let
helpers = import ../helpers.nix args;
basePluginPath = ["plugins" "indent-blankline"];
in {
# TODO: Those warnings were introduced on 2023/10/17.

View file

@ -1,12 +1,11 @@
{
lib,
pkgs,
helpers,
config,
pkgs,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in {
}:
with lib; {
options.plugins.instant = {
enable = mkEnableOption "instant.nvim";

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.intellitab;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.intellitab = {

View file

@ -1,11 +1,11 @@
{
pkgs,
lib,
helpers,
config,
pkgs,
...
}: let
cfg = config.plugins.lastplace;
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.lastplace =

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.leap;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.leap =
helpers.extraOptionsOptions

View file

@ -1,6 +1,6 @@
{
pkgs,
lib,
pkgs,
...
} @ args:
with lib;

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.mark-radar;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.mark-radar =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.mini;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.mini = {
enable = mkEnableOption "mini.nvim";

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.mkdnflow;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.mkdnflow =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.multicursors;
helpers = import ../helpers.nix {inherit lib;};
keyOptionType = with types;
attrsOf (

View file

@ -1,12 +1,12 @@
{
lib,
pkgs,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.navbuddy;
helpers = import ../helpers.nix {inherit lib;};
percentageType = types.ints.between 0 100;
mkPercentageOpt = default: helpers.defaultNullOpts.mkNullable percentageType (toString default);

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.neogen;
helpers = import ../helpers.nix {inherit lib;};
keymapDef = {
generate = {

View file

@ -1,11 +1,11 @@
{
pkgs,
lib,
helpers,
config,
pkgs,
...
}: let
cfg = config.plugins.neorg;
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.neorg =

View file

@ -1,29 +1,28 @@
{
config,
lib,
helpers,
config,
pkgs,
...
} @ args: let
helpers = import ../helpers.nix args;
in
with lib; {
options.plugins.netman = {
enable = mkEnableOption "netman.nvim, a framework to access remote resources";
}:
with lib; {
options.plugins.netman = {
enable = mkEnableOption "netman.nvim, a framework to access remote resources";
package = helpers.mkPackageOption "netman.nvim" pkgs.vimPlugins.netman-nvim;
package = helpers.mkPackageOption "netman.nvim" pkgs.vimPlugins.netman-nvim;
neoTreeIntegration = mkEnableOption "support for netman as a neo-tree source";
neoTreeIntegration = mkEnableOption "support for netman as a neo-tree source";
};
config = let
cfg = config.plugins.netman;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = ''
require("netman")
'';
plugins.neo-tree.extraSources = mkIf cfg.neoTreeIntegration ["netman.ui.neo-tree"];
};
config = let
cfg = config.plugins.netman;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = ''
require("netman")
'';
plugins.neo-tree.extraSources = mkIf cfg.neoTreeIntegration ["netman.ui.neo-tree"];
};
}
}

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.nix-develop;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.nix-develop =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.notify;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.notify =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.nvim-autopairs;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.nvim-autopairs =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.nvim-bqf;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.nvim-bqf =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.nvim-colorizer;
helpers = import ../helpers.nix {inherit lib;};
colorizer-options = {
RGB = mkOption {

View file

@ -1,94 +1,93 @@
{
pkgs,
lib,
helpers,
pkgs,
config,
...
} @ args: let
helpers = import ../helpers.nix args;
in
with lib; {
options.plugins.nvim-osc52 = {
enable = mkEnableOption "nvim-osc52, a plugin to use OSC52 sequences to copy/paste";
}:
with lib; {
options.plugins.nvim-osc52 = {
enable = mkEnableOption "nvim-osc52, a plugin to use OSC52 sequences to copy/paste";
package = helpers.mkPackageOption "nvim-osc52" pkgs.vimPlugins.nvim-osc52;
package = helpers.mkPackageOption "nvim-osc52" pkgs.vimPlugins.nvim-osc52;
maxLength =
helpers.defaultNullOpts.mkInt 0 "Maximum length of selection (0 for no limit)";
silent = helpers.defaultNullOpts.mkBool false "Disable message on successful copy";
trim = helpers.defaultNullOpts.mkBool false "Trim text before copy";
maxLength =
helpers.defaultNullOpts.mkInt 0 "Maximum length of selection (0 for no limit)";
silent = helpers.defaultNullOpts.mkBool false "Disable message on successful copy";
trim = helpers.defaultNullOpts.mkBool false "Trim text before copy";
keymaps = {
enable = mkEnableOption "keymaps for copying using OSC52";
keymaps = {
enable = mkEnableOption "keymaps for copying using OSC52";
silent = mkOption {
type = types.bool;
description = "Wether nvim-osc52 keymaps should be silent";
default = false;
};
silent = mkOption {
type = types.bool;
description = "Wether nvim-osc52 keymaps should be silent";
default = false;
};
copy = mkOption {
type = types.str;
description = "Copy into the system clipboard using OSC52";
default = "<leader>y";
};
copy = mkOption {
type = types.str;
description = "Copy into the system clipboard using OSC52";
default = "<leader>y";
};
copyLine = mkOption {
type = types.str;
description = "Copy line into the system clipboard using OSC52";
default = "<leader>yy";
};
copyLine = mkOption {
type = types.str;
description = "Copy line into the system clipboard using OSC52";
default = "<leader>yy";
};
copyVisual = mkOption {
type = types.str;
description = "Copy visual selection into the system clipboard using OSC52";
default = "<leader>y";
};
copyVisual = mkOption {
type = types.str;
description = "Copy visual selection into the system clipboard using OSC52";
default = "<leader>y";
};
};
};
config = let
cfg = config.plugins.nvim-osc52;
setupOptions = with cfg; {
inherit silent trim;
max_length = maxLength;
};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
config = let
cfg = config.plugins.nvim-osc52;
setupOptions = with cfg; {
inherit silent trim;
max_length = maxLength;
};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
keymaps = with cfg.keymaps;
mkIf enable
[
{
mode = "n";
key = copy;
action = "require('osc52').copy_operator";
lua = true;
options = {
expr = true;
inherit silent;
};
}
{
mode = "n";
key = copyLine;
action = "${copy}_";
options = {
remap = true;
inherit silent;
};
}
{
mode = "v";
key = copyVisual;
action = "require('osc52').copy_visual";
lua = true;
options.silent = silent;
}
];
keymaps = with cfg.keymaps;
mkIf enable
[
{
mode = "n";
key = copy;
action = "require('osc52').copy_operator";
lua = true;
options = {
expr = true;
inherit silent;
};
}
{
mode = "n";
key = copyLine;
action = "${copy}_";
options = {
remap = true;
inherit silent;
};
}
{
mode = "v";
key = copyVisual;
action = "require('osc52').copy_visual";
lua = true;
options.silent = silent;
}
];
extraConfigLua = ''
require('osc52').setup(${helpers.toLuaObject setupOptions})
'';
};
}
extraConfigLua = ''
require('osc52').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.nvim-ufo;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.nvim-ufo =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.oil;
helpers = import ../helpers.nix {inherit lib;};
fractionType = types.numbers.between 0.0 1.0;

View file

@ -1,12 +1,11 @@
{
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
with lib; {
options.plugins.persistence =
helpers.extraOptionsOptions
// {

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.presence-nvim;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.presence-nvim =

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.project-nvim;
helpers = import ../helpers.nix {inherit lib pkgs;};
in {
options.plugins.project-nvim =
helpers.extraOptionsOptions

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.quickmath;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.quickmath = {
enable = mkEnableOption "quickmath.nvim";

View file

@ -1,12 +1,11 @@
{
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
with lib; {
options.plugins.refactoring =
helpers.extraOptionsOptions
// {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.specs;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.specs = {
enable = mkEnableOption "specs-nvim";

View file

@ -1,13 +1,13 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
pluginName = "spider";
cfg = config.plugins.${pluginName};
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.${pluginName} =
helpers.extraOptionsOptions

View file

@ -1,6 +1,6 @@
{
pkgs,
lib,
pkgs,
...
} @ args: let
helpers = import ../helpers.nix {inherit lib;};

View file

@ -1,12 +1,12 @@
{
config,
lib,
helpers,
config,
pkgs,
...
} @ attrs:
}:
with lib; let
cfg = config.plugins.tmux-navigator;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.tmux-navigator = {
enable = mkEnableOption "Tmux-Navigator (see https://github.com/christoomey/vim-tmux-navigator for tmux installation instruction)";

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.todo-comments;
helpers = import ../helpers.nix {inherit lib;};
commands = {
todoQuickFix = "TodoQuickFix";

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.toggleterm;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.toggleterm = {
enable = mkEnableOption "toggleterm";

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.undotree;
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.undotree = {

View file

@ -1,12 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.vim-bbye;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.vim-bbye = {
enable = mkEnableOption "vim-bbye";

View file

@ -1,12 +1,11 @@
{
lib,
helpers,
pkgs,
config,
lib,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in {
}:
with lib; {
options.plugins.vim-matchup = {
enable = mkEnableOption "vim-matchup";

View file

@ -1,12 +1,11 @@
{
lib,
helpers,
pkgs,
config,
lib,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in {
}:
with lib; {
options.plugins.which-key = {
enable =
mkEnableOption

View file

@ -1,19 +1,12 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.wilder;
helpers = import ../helpers.nix {inherit lib;};
boolToInt = value:
if value == null
then null
else if value
then "1"
else "0";
mkKeyOption = default: desc:
helpers.defaultNullOpts.mkNullable

View file

@ -1,12 +1,11 @@
{
pkgs,
config,
lib,
helpers,
config,
pkgs,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in {
}:
with lib; {
options.plugins.zk = {
enable = mkEnableOption "zk.nvim, a plugin to integrate with zk";