Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lua/image/image.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ function Image:render(geometry)
local was_rendered = renderer.render(self)

-- utils.debug(
-- ("[image] render: %s, success: %s x: %s, y: %s, width: %s, height: %s"):format(
-- self.id,
-- ("[image] success: %s x: %s, y: %s, width: %s, height: %s"):format(
-- was_rendered,
-- self.geometry.x,
-- self.geometry.y,
Expand Down Expand Up @@ -260,7 +259,7 @@ local from_file = function(path, options, state)

-- bail if not an image
if not utils.magic.is_image(absolute_original_path) then
utils.debug(("image.nvim: not an image: %s"):format(absolute_original_path))
-- utils.debug(("image.nvim: not an image: %s"):format(absolute_original_path))
return nil
end

Expand Down
7 changes: 5 additions & 2 deletions lua/image/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,18 @@ api.setup = function(options)
})

-- force rerender on resize (handles VimResized as well)
vim.api.nvim_create_autocmd({ "WinResized" }, {
vim.api.nvim_create_autocmd({ "WinResized", "WinNew" }, {
group = group,
callback = function()
-- bail if not enabled
if not state.enabled then return end

local images = api.get_images()
for _, current_image in ipairs(images) do
if current_image.window ~= nil then current_image:render() end
if current_image.window ~= nil then
current_image:clear()
current_image:render()
end
end
end,
})
Expand Down
9 changes: 8 additions & 1 deletion lua/image/integrations/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ return document.create_document_integration({
-- TODO: fix node:range() taking into account the extmarks for SOME FKING REASON
if key == "image" then
local start_row, start_col, end_row, end_col = node:range()

current_image = {
node = node,
range = { start_row = start_row, start_col = start_col, end_row = end_row, end_col = end_col },
range = {
start_row = start_row,
start_col = start_col,
end_row = end_row,
end_col = end_col,
},
}

elseif current_image and key == "url" then
current_image.url = value
table.insert(images, current_image)
Expand Down
Loading
Loading