-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugins/utils/nvim-osc52: add desc option #1704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,34 +12,40 @@ with lib; | |
|
||
package = helpers.mkPluginPackageOption "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"; | ||
enable = mkEnableOption "keymaps for copying using OSC52."; | ||
|
||
silent = mkOption { | ||
type = types.bool; | ||
description = "Whether nvim-osc52 keymaps should be silent"; | ||
description = "Whether nvim-osc52 keymaps should be silent."; | ||
default = false; | ||
}; | ||
|
||
desc = mkOption { | ||
type = types.str; | ||
description = "Keymap description."; | ||
default = "Copy using OSC52"; | ||
}; | ||
|
||
copy = mkOption { | ||
type = types.str; | ||
description = "Copy into the system clipboard using OSC52"; | ||
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"; | ||
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"; | ||
description = "Copy visual selection into the system clipboard using OSC52."; | ||
default = "<leader>y"; | ||
}; | ||
}; | ||
|
@@ -65,6 +71,7 @@ with lib; | |
action.__raw = "require('osc52').copy_operator"; | ||
options = { | ||
expr = true; | ||
desc = "Copy using OSC52"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also inherit |
||
inherit silent; | ||
}; | ||
} | ||
|
@@ -74,14 +81,18 @@ with lib; | |
action = "${copy}_"; | ||
options = { | ||
remap = true; | ||
inherit desc; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, instead of adding a Maybe that's a little over-engineered... Do you think it's ok that all keymaps have the same desc though? Maybe desc could use: {
# allow functions or strings
type = either str (functionTo str);
# normalise string to a function that ignores its argument
apply = v: if isStr v then x: v else v;
# Sane default uses the context provided
default = name:
"Copy "
+ (optionalString (name != "") "${name} ")
+ "using OSC52.";
} The option would then be a function (str -> str) that maps |
||
inherit silent; | ||
}; | ||
} | ||
{ | ||
mode = "v"; | ||
key = copyVisual; | ||
action.__raw = "require('osc52').copy_visual"; | ||
options.silent = silent; | ||
options = { | ||
inherit silent; | ||
inherit desc; | ||
}; | ||
} | ||
]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better approach here would be to refactor the keymap's option in line with #603 (i.e. using
mkMapOptionSubmodule
)If that helper doesn't currently suit this use-case we should consider either making the helper more flexible or changing how the keymaps option here works (breaking changes if absolutely necessary).
That said, this is another plugin that needs a switch to mkNeovimPlugin, so IMO it isn't worth refactoring anything until we make that larger switch.