2023-03-16 11:18:54 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
pkgs,
|
2023-03-16 11:18:54 +01:00
|
|
|
config,
|
|
|
|
...
|
2023-11-06 15:04:08 +01:00
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options.plugins.nvim-osc52 = {
|
|
|
|
enable = mkEnableOption "nvim-osc52, a plugin to use OSC52 sequences to copy/paste";
|
2023-03-26 15:44:45 +02:00
|
|
|
|
2024-05-17 14:09:20 +02:00
|
|
|
package = helpers.mkPluginPackageOption "nvim-osc52" pkgs.vimPlugins.nvim-osc52;
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
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";
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
keymaps = {
|
|
|
|
enable = mkEnableOption "keymaps for copying using OSC52";
|
2023-09-15 14:35:13 +02:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
silent = mkOption {
|
|
|
|
type = types.bool;
|
2024-03-07 19:44:13 +01:00
|
|
|
description = "Whether nvim-osc52 keymaps should be silent";
|
2023-11-06 15:04:08 +01:00
|
|
|
default = false;
|
|
|
|
};
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
copy = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Copy into the system clipboard using OSC52";
|
|
|
|
default = "<leader>y";
|
|
|
|
};
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
copyLine = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Copy line into the system clipboard using OSC52";
|
|
|
|
default = "<leader>yy";
|
|
|
|
};
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
copyVisual = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Copy visual selection into the system clipboard using OSC52";
|
|
|
|
default = "<leader>y";
|
2023-03-16 11:18:54 +01:00
|
|
|
};
|
|
|
|
};
|
2023-11-06 15:04:08 +01:00
|
|
|
};
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.plugins.nvim-osc52;
|
|
|
|
setupOptions = with cfg; {
|
|
|
|
inherit silent trim;
|
|
|
|
max_length = maxLength;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
|
|
extraPlugins = [ cfg.package ];
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
keymaps =
|
|
|
|
with cfg.keymaps;
|
|
|
|
mkIf enable [
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
key = copy;
|
2024-02-03 17:42:24 +01:00
|
|
|
action.__raw = "require('osc52').copy_operator";
|
2023-11-06 15:04:08 +01:00
|
|
|
options = {
|
|
|
|
expr = true;
|
|
|
|
inherit silent;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "n";
|
|
|
|
key = copyLine;
|
|
|
|
action = "${copy}_";
|
|
|
|
options = {
|
|
|
|
remap = true;
|
|
|
|
inherit silent;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
mode = "v";
|
|
|
|
key = copyVisual;
|
2024-02-03 17:42:24 +01:00
|
|
|
action.__raw = "require('osc52').copy_visual";
|
2023-11-06 15:04:08 +01:00
|
|
|
options.silent = silent;
|
|
|
|
}
|
|
|
|
];
|
2023-03-16 11:18:54 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
extraConfigLua = ''
|
|
|
|
require('osc52').setup(${helpers.toLuaObject setupOptions})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|