Skip to content

Commit 78f6166

Browse files
xamcostMattSturgeon
authored andcommitted
plugins/image: add resolveImagePath option
1 parent 33097dc commit 78f6166

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

plugins/by-name/image/default.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ in
6666
filetypes = helpers.defaultNullOpts.mkListOf types.str filetypesDefault ''
6767
Markdown extensions (ie. quarto) can go here.
6868
'';
69+
70+
resolveImagePath = helpers.mkNullOrLuaFn' {
71+
description = "Configures how to resolve image paths.";
72+
example = lib.literalExpression ''
73+
lib.nixvim.mkRaw '''
74+
function(document_path, image_path, fallback)
75+
-- document_path is the path to the file that contains the image
76+
-- image_path is the potentially relative path to the image. For markdown, it's `![](this text)`
77+
-- fallback is the default behavior
78+
return fallback(document_path, image_path)
79+
end
80+
''';
81+
'';
82+
};
6983
};
7084
in
7185
mapAttrs mkIntegrationOptions {
@@ -150,6 +164,7 @@ in
150164
download_remote_images = v.downloadRemoteImages;
151165
only_render_image_at_cursor = v.onlyRenderImageAtCursor;
152166
inherit (v) filetypes;
167+
resolve_image_path = v.resolveImagePath;
153168
};
154169
in
155170
mapAttrs (_: processIntegrationOptions) integrations;

0 commit comments

Comments
 (0)