images/image-nvim: make lib calls more explicit

This commit is contained in:
NotAShelf 2024-02-26 11:54:20 +03:00
parent d2af30545d
commit 30fb2e4f28
No known key found for this signature in database
GPG Key ID: 02D1DD3FA08B6B29
2 changed files with 19 additions and 15 deletions

View File

@ -1,10 +1,11 @@
{ {
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib) nvim mkIf attrValues; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.utility.images.image-nvim; cfg = config.vim.utility.images.image-nvim;
in { in {
@ -18,9 +19,9 @@ in {
"magick" "magick"
]; ];
luaConfigRC.image-nvim = nvim.dag.entryAnywhere '' luaConfigRC.image-nvim = entryAnywhere ''
require("image").setup( require("image").setup(
${nvim.lua.toLuaObject cfg.setupOpts} ${toLuaObject cfg.setupOpts}
) )
''; '';
}; };

View File

@ -3,14 +3,17 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption nvim types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum listOf str nullOr int;
inherit (lib.nvim.lua) mkPluginSetupOption;
in { in {
options.vim.utility.images.image-nvim = { options.vim.utility.images.image-nvim = {
enable = mkEnableOption "image support in Neovim [image.nvim]"; enable = mkEnableOption "image support in Neovim [image.nvim]";
setupOpts = nvim.types.mkPluginSetupOption "image.nvim" { setupOpts = mkPluginSetupOption "image.nvim" {
backend = mkOption { backend = mkOption {
type = types.enum ["kitty" "ueberzug"]; type = enum ["kitty" "ueberzug"];
default = "ueberzug"; default = "ueberzug";
description = '' description = ''
The backend to use for rendering images. The backend to use for rendering images.
@ -28,7 +31,7 @@ in {
downloadRemoteImages = mkEnableOption "downloading remote images"; downloadRemoteImages = mkEnableOption "downloading remote images";
onlyRenderAtCursor = mkEnableOption "only rendering images at cursor"; onlyRenderAtCursor = mkEnableOption "only rendering images at cursor";
filetypes = mkOption { filetypes = mkOption {
type = with types; listOf str; type = listOf str;
default = ["markdown" "vimwiki"]; default = ["markdown" "vimwiki"];
description = '' description = ''
Filetypes to enable image.nvim in. Markdown extensions Filetypes to enable image.nvim in. Markdown extensions
@ -43,7 +46,7 @@ in {
downloadRemoteImages = mkEnableOption "downloading remote images"; downloadRemoteImages = mkEnableOption "downloading remote images";
onlyRenderAtCursor = mkEnableOption "only rendering images at cursor"; onlyRenderAtCursor = mkEnableOption "only rendering images at cursor";
filetypes = mkOption { filetypes = mkOption {
type = with types; listOf str; type = listOf str;
default = ["neorg"]; default = ["neorg"];
description = '' description = ''
Filetypes to enable image.nvim in. Filetypes to enable image.nvim in.
@ -52,7 +55,7 @@ in {
}; };
maxWidth = mkOption { maxWidth = mkOption {
type = with types; nullOr int; type = nullOr int;
default = null; default = null;
description = '' description = ''
The maximum width of images to render. Images larger than The maximum width of images to render. Images larger than
@ -62,7 +65,7 @@ in {
}; };
maxHeight = mkOption { maxHeight = mkOption {
type = with types; nullOr int; type = nullOr int;
default = null; default = null;
description = '' description = ''
The maximum height of images to render. Images larger than The maximum height of images to render. Images larger than
@ -71,7 +74,7 @@ in {
}; };
maxWidthWindowPercentage = mkOption { maxWidthWindowPercentage = mkOption {
type = with types; nullOr int; type = nullOr int;
default = null; default = null;
description = '' description = ''
The maximum width of images to render as a percentage of the The maximum width of images to render as a percentage of the
@ -81,7 +84,7 @@ in {
}; };
maxHeightWindowPercentage = mkOption { maxHeightWindowPercentage = mkOption {
type = with types; nullOr int; type = nullOr int;
default = 50; default = 50;
description = '' description = ''
The maximum height of images to render as a percentage of the The maximum height of images to render as a percentage of the
@ -93,7 +96,7 @@ in {
windowOverlapClear = { windowOverlapClear = {
enable = mkEnableOption "clearing of images when they overlap with the window"; enable = mkEnableOption "clearing of images when they overlap with the window";
ftIgnore = mkOption { ftIgnore = mkOption {
type = with types; listOf str; type = listOf str;
default = ["cmp_menu" "cmp_docs" ""]; default = ["cmp_menu" "cmp_docs" ""];
description = '' description = ''
Filetypes to ignore window overlap clearing in. Filetypes to ignore window overlap clearing in.
@ -103,7 +106,7 @@ in {
editorOnlyRenderWhenFocused = mkEnableOption "only rendering images when the editor is focused"; editorOnlyRenderWhenFocused = mkEnableOption "only rendering images when the editor is focused";
hijackFilePatterns = mkOption { hijackFilePatterns = mkOption {
type = with types; listOf str; type = listOf str;
default = ["*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp"]; default = ["*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp"];
description = '' description = ''
File patterns to hijack for image.nvim. This is useful for File patterns to hijack for image.nvim. This is useful for