nix-community.nixvim/modules/clipboard.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.3 KiB
Nix
Raw Permalink Normal View History

{
lib,
config,
pkgs,
...
}:
let
cfg = config.clipboard;
in
{
options = {
clipboard = {
2024-08-30 14:37:41 -05:00
register = lib.mkOption {
description = ''
Sets the register to use for the clipboard.
Learn more in [`:h 'clipboard'`](https://neovim.io/doc/user/options.html#'clipboard').
'';
type = with lib.types; nullOr (maybeRaw (either str (listOf (maybeRaw str))));
default = null;
example = "unnamedplus";
};
2024-08-30 14:37:41 -05:00
providers = lib.mkOption {
type = lib.types.submodule {
options =
2024-08-30 14:37:41 -05:00
lib.mapAttrs
(name: packageName: {
2024-08-30 14:37:41 -05:00
enable = lib.mkEnableOption name;
package = lib.mkPackageOption pkgs packageName { };
})
{
wl-copy = "wl-clipboard";
xclip = "xclip";
xsel = "xsel";
};
};
default = { };
description = ''
Package(s) to use as the clipboard provider.
Learn more at `:h clipboard`.
'';
};
};
};
config = {
2024-08-30 14:37:41 -05:00
opts.clipboard = lib.mkIf (cfg.register != null) cfg.register;
2024-08-30 14:37:41 -05:00
extraPackages = lib.mapAttrsToList (n: v: v.package) (
lib.filterAttrs (n: v: v.enable) cfg.providers
);
};
}