mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
modules/clipboard: add new module to manage clipboard option and provider (#346)
This commit is contained in:
parent
9c8bee9da6
commit
73e8649b20
2 changed files with 73 additions and 0 deletions
56
modules/clipboard.nix
Normal file
56
modules/clipboard.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.clipboard;
|
||||
in {
|
||||
options = {
|
||||
clipboard = {
|
||||
register = mkOption {
|
||||
description = ''
|
||||
Sets the register to use for the clipboard.
|
||||
Learn more at https://neovim.io/doc/user/options.html#'clipboard'.
|
||||
'';
|
||||
type = with types;
|
||||
nullOr
|
||||
(either str (listOf str));
|
||||
default = null;
|
||||
example = "unnamedplus";
|
||||
};
|
||||
|
||||
providers = mkOption {
|
||||
type = types.submodule {
|
||||
options =
|
||||
mapAttrs
|
||||
(
|
||||
name: packageName: {
|
||||
enable = mkEnableOption name;
|
||||
package = mkPackageOption pkgs packageName {};
|
||||
}
|
||||
)
|
||||
{
|
||||
xclip = "xclip";
|
||||
xsel = "xsel";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = ''
|
||||
Package(s) to use as the clipboard provider.
|
||||
Learn more at `:h clipboard`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
options.clipboard = mkIf (!isNull cfg.register) cfg.register;
|
||||
|
||||
extraPackages =
|
||||
mapAttrsToList
|
||||
(n: v: v.package)
|
||||
(filterAttrs (n: v: v.enable) cfg.providers);
|
||||
};
|
||||
}
|
17
tests/test-sources/modules/clipboard.nix
Normal file
17
tests/test-sources/modules/clipboard.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{pkgs}: {
|
||||
example-with-str = {
|
||||
clipboard = {
|
||||
register = "unnamed";
|
||||
|
||||
providers.xclip.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
example-with-package = {
|
||||
clipboard = {
|
||||
register = ["unnamed" "unnamedplus"];
|
||||
|
||||
providers.xsel.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue