mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-29 20:04:28 +02:00
misc: refactor imports, prefer adding helpers
to args rather than importing it
This commit is contained in:
parent
541b694873
commit
b6724702b4
160 changed files with 697 additions and 736 deletions
|
@ -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})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue