File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ function M.on_exit(msg, opts)
5151 if freeze_code .config .copy == true then
5252 freeze_code .copy (freeze_code .config )
5353 end
54+ if freeze_code .config .open == true then
55+ freeze_code .open (freeze_code .config )
56+ end
5457 if opts and opts .freeze then
5558 vim .wait (5000 , function ()
5659 local image_path = vim .loop .fs_fstat (opts .freeze .output )
@@ -127,4 +130,23 @@ M.copy = function(opts)
127130 logger .info (" [freeze-code.nvim] image copied to clipboard" )
128131end
129132
133+ local open_by_os = function (opts )
134+ local cmd = {}
135+ local filename = vim .fn .expand (opts .output )
136+ if is_win then
137+ cmd = { " explorer" , filename }
138+ else
139+ cmd = { " open" , filename }
140+ end
141+ return vim .fn .system (table.concat (cmd , " " ))
142+ end
143+
144+ M .open = function (opts )
145+ open_by_os (opts )
146+ if vim .v .shell_error ~= 0 then
147+ logger .err_once (" [freeze-code.nvim] error while opening image" )
148+ return
149+ end
150+ end
151+
130152return M
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ freeze_code.copy = function(opts)
5454 commands .copy (opts )
5555end
5656
57+ --- @class FreezeCode
58+ --- @field open function : Opening image in default image viewer
59+ freeze_code .open = function (opts )
60+ commands .open (opts )
61+ end
62+
5763local create_autocmds = function ()
5864 vim .api .nvim_create_user_command (" Freeze" , function (opts )
5965 if opts .count > 0 then
You can’t perform that action at this time.
0 commit comments