Skip to content

Commit 116c749

Browse files
authored
fix(preview): update image.nvim integration (#1648)
1 parent 2d013db commit 116c749

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/neo-tree/sources/common/preview.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,14 @@ end
273273

274274
---@param winid number
275275
---@param bufnr number
276+
---@return Image[]|false result Images if the buffer was successfully hijacked, otherwise false
276277
local function try_load_image_nvim_buf(winid, bufnr)
278+
-- notify only image.nvim to let it try and hijack
279+
vim.opt.eventignore:remove("BufWinEnter")
280+
vim.api.nvim_win_call(winid, function()
281+
vim.api.nvim_exec_autocmds("BufWinEnter", { group = "image.nvim", buffer = bufnr })
282+
end)
283+
vim.opt.eventignore:append("BufWinEnter")
277284
if vim.bo[bufnr].filetype ~= "image_nvim" then
278285
return false
279286
end
@@ -283,7 +290,7 @@ local function try_load_image_nvim_buf(winid, bufnr)
283290
log.debug("You'll need to install image.nvim to use this command: " .. image_nvim_url)
284291
return false
285292
end
286-
return mod.hijack_buffer(vim.api.nvim_buf_get_name(bufnr), winid, bufnr)
293+
return mod.get_images({ buffer = bufnr, window = winid })
287294
end
288295

289296
---Set the buffer in the preview window without executing BufEnter or BufWinEnter autocommands.

0 commit comments

Comments
 (0)