Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #62 Rewrote the renderer to use vim.fn.screenpos #266

Merged
merged 2 commits into from
Jan 17, 2025
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 @@ -79,8 +79,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 @@ -258,7 +257,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 @@ -259,12 +259,15 @@ 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()
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 @@ -36,10 +36,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