mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-24 12:45:24 +02:00
plugins/nvim-osc52: init + tests (#261)
nvim-osc52 is a plugin that allows to copy from neovim using OSC52 control sequences (works through SSH for example)
This commit is contained in:
parent
f5f33b5390
commit
c6fa30b81c
7 changed files with 144 additions and 0 deletions
85
plugins/utils/nvim-osc52.nix
Normal file
85
plugins/utils/nvim-osc52.nix
Normal file
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
} @ args: let
|
||||
plugin-defs = import ../plugin-defs.nix {inherit pkgs;};
|
||||
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";
|
||||
package = helpers.mkPackageOption "nvim-osc52" plugin-defs.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";
|
||||
|
||||
keymaps = {
|
||||
enable = mkEnableOption "keymaps for copying using OSC52";
|
||||
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";
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.nvim-osc52;
|
||||
setupOptions = with cfg; {
|
||||
inherit silent trim;
|
||||
max_length = maxLength;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
maps = mkIf cfg.keymaps.enable {
|
||||
normal = {
|
||||
"${cfg.keymaps.copy}" = {
|
||||
action = "require('osc52').copy_operator";
|
||||
expr = true;
|
||||
lua = true;
|
||||
silent = cfg.keymaps.silent;
|
||||
};
|
||||
"${cfg.keymaps.copyLine}" = {
|
||||
action = "${cfg.keymaps.copy}_";
|
||||
remap = true;
|
||||
silent = cfg.keymaps.silent;
|
||||
};
|
||||
};
|
||||
visual = {
|
||||
"${cfg.keymaps.copyVisual}" = {
|
||||
action = "require('osc52').copy_visual";
|
||||
lua = true;
|
||||
silent = cfg.keymaps.silent;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
extraConfigLua = ''
|
||||
require('osc52').setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue