nix-community.nixvim/plugins/by-name/clipboard-image/default.nix

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

118 lines
2.9 KiB
Nix
Raw Normal View History

2024-01-24 09:48:51 +01:00
{
lib,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
2024-01-24 09:48:51 +01:00
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "clipboard-image";
packPathName = "clipboard-image.nvim";
package = "clipboard-image-nvim";
2024-01-24 09:48:51 +01:00
maintainers = [ lib.maintainers.GaetanLepage ];
2024-01-24 09:48:51 +01:00
description = ''
Plugin to paste images from clipboard into Neovim.
'';
2024-01-24 09:48:51 +01:00
extraOptions = {
clipboardPackage = lib.mkPackageOption pkgs "clipboard provider" {
nullable = true;
default = null;
example = [ "wl-clipboard" ];
extraDescription = ''
${"\n\n"}
2024-01-24 09:48:51 +01:00
Recommended:
- X11: `pkgs.xclip`
- Wayland: `pkgs.wl-clipboard`
- MacOS: `pkgs.pngpaste`
'';
};
};
2024-01-24 09:48:51 +01:00
settingsOptions = {
default = {
img_dir =
defaultNullOpts.mkNullable
(types.oneOf [
types.str
(types.listOf types.str)
types.rawLua
])
"img"
''
Directory name where the image will be pasted to.
> [!Note]
> If you want to create nested dir, it is better to use table since windows and unix have different path separator.
2024-01-24 09:48:51 +01:00
'';
img_dir_txt = defaultNullOpts.mkNullable (types.oneOf [
types.str
(types.listOf types.str)
types.rawLua
]) "img" "Directory that will be inserted into text/buffer.";
img_name = defaultNullOpts.mkStr {
__raw = "function() return os.date('%Y-%m-%d-%H-%M-%S') end";
} "Image's name.";
img_handler = defaultNullOpts.mkLuaFn "function(img) end" ''
Function that will handle image after pasted.
> [!Note]
> `img` is a table that contain pasted image's `{name}` and `{path}`.
'';
affix = defaultNullOpts.mkStr' {
pluginDefault = lib.literalMD ''
`default`: `"{img_path}"`
`markdown`: `"![]({img_path})"`
'';
description = "String that sandwiches the image's path.";
example = lib.literalExpression ''
> [!Note]
> ```nix
> # You can use line break escape sequence
> affix = "<\n %s\n>";
> ```
> ```nix
> # Or lua's double square brackets
> affix.__raw = \'\'
> [[<
> %s
> >]]
> \'\'
> ```
'';
2024-01-24 09:48:51 +01:00
};
};
2024-05-05 19:39:35 +02:00
};
2024-01-24 09:48:51 +01:00
settingsExample = {
settings = {
img_dir = "img";
img_dir_txt = "img";
img_name.__raw = "function() return os.date('%Y-%m-%d-%H-%M-%S') end";
img_handler.__raw = "function(img) end";
affix = "![]({img_path})";
};
};
2024-01-24 09:48:51 +01:00
extraConfig = cfg: {
2024-04-23 16:41:27 +02:00
extraPackages = [ cfg.clipboardPackage ];
2024-01-24 09:48:51 +01:00
};
# TODO: Deprecated in 2025-02-01
inherit (import ./deprecations.nix { inherit lib; })
imports
deprecateExtraOptions
optionsRenamedToSettings
;
2024-01-24 09:48:51 +01:00
}