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

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

136 lines
3.6 KiB
Nix
Raw Normal View History

2023-12-29 11:29:26 +01:00
{
lib,
...
}:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
2023-12-29 11:29:26 +01:00
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "image";
packPathName = "image.nvim";
package = "image-nvim";
2023-12-29 11:29:26 +01:00
maintainers = [ lib.maintainers.GaetanLepage ];
2023-12-29 11:29:26 +01:00
2025-04-06 17:17:51 +02:00
# TODO: option deprecations added 2025-03-20. Remove after 25.05
2025-04-06 17:21:36 +02:00
# TODO: curlPackage and ueberzugPackage deprecations added 2025-04-06. Remove after 25.05
inherit (import ./deprecations.nix lib)
deprecateExtraOptions
optionsRenamedToSettings
imports
;
2023-12-29 11:29:26 +01:00
settingsOptions = {
2023-12-29 11:29:26 +01:00
backend =
defaultNullOpts.mkEnumFirstDefault
2023-12-29 11:29:26 +01:00
[
"kitty"
"ueberzug"
]
''
All the backends support rendering inside Tmux.
- kitty - best in class, works great and is very snappy
- ueberzug - backed by ueberzugpp, supports any terminal, but has lower performance
- Supports multiple images thanks to @jstkdng.
> [!Note]
> When choosing the `"ueberzug"` backend, nixvim will automatically add `ueberzugpp` as a dependency.
> Set `ueberzugPackage = null` to disable this behavior.
2023-12-29 11:29:26 +01:00
'';
integrations =
defaultNullOpts.mkAttrsOf types.anything
{
markdown.enabled = true;
typst.enabled = true;
neorg.enabled = true;
syslang.enabled = true;
html.enabled = false;
css.enabled = false;
}
''
Per-filetype integrations.
'';
max_width = defaultNullOpts.mkUnsignedInt null ''
Image maximum width.
'';
max_height = defaultNullOpts.mkUnsignedInt null ''
Image maximum height.
'';
max_width_window_percentage = defaultNullOpts.mkUnsignedInt 100 ''
2023-12-29 11:29:26 +01:00
Image maximum width as a percentage of the window width.
'';
max_height_window_percentage = defaultNullOpts.mkUnsignedInt 50 ''
2023-12-29 11:29:26 +01:00
Image maximum height as a percentage of the window height.
'';
window_overlap_clear_enabled = defaultNullOpts.mkBool false ''
2023-12-29 11:29:26 +01:00
Toggles images when windows are overlapped.
'';
window_overlap_clear_ft_ignore =
defaultNullOpts.mkListOf types.str
2024-06-11 16:54:41 +01:00
[
"cmp_menu"
"cmp_docs"
"snacks_notif"
"scrollview"
"scrollview_sign"
2024-06-11 16:54:41 +01:00
]
2023-12-29 11:29:26 +01:00
''
Toggles images when windows are overlapped.
'';
editor_only_render_when_focused = defaultNullOpts.mkBool false ''
2023-12-29 11:29:26 +01:00
Auto show/hide images when the editor gains/looses focus.
'';
tmux_show_only_in_active_window = defaultNullOpts.mkBool false ''
2023-12-29 11:29:26 +01:00
Auto show/hide images in the correct Tmux window (needs visual-activity off).
'';
hijack_file_patterns =
defaultNullOpts.mkListOf types.str
2024-06-11 16:54:41 +01:00
[
"*.png"
"*.jpg"
"*.jpeg"
"*.gif"
"*.webp"
"*.avif"
2024-06-11 16:54:41 +01:00
]
2023-12-29 11:29:26 +01:00
''
Render image files as images when opened.
'';
};
settingsExample = {
backend = "kitty";
max_width = 100;
max_height = 12;
max_height_window_percentage.__raw = "math.huge";
max_width_window_percentage.__raw = "math.huge";
window_overlap_clear_enabled = true;
window_overlap_clear_ft_ignore = [
"cmp_menu"
"cmp_docs"
""
];
};
2024-05-05 19:39:35 +02:00
extraConfig = cfg: {
2025-04-06 17:17:51 +02:00
# In theory, we could remove that if the user explicitly disables `downloadRemoteImages` for
# all integrations but shipping `curl` is not too heavy.
2025-04-06 17:21:36 +02:00
dependencies = {
curl.enable = lib.mkDefault true;
ueberzug.enable = lib.mkIf (cfg.settings.backend == "ueberzug") (lib.mkDefault true);
};
2023-12-29 11:29:26 +01:00
};
}