nvim: Fix image.nvim functionality

Track master since no new version has been tagged. Change some settings
around and make installation more robust using the new lazy rocks
system.
This commit is contained in:
Marty Oehme 2025-02-06 13:13:41 +01:00
parent 9d15bc79f4
commit 101937a8c2
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 32 additions and 36 deletions

View file

@ -22,7 +22,7 @@
"glance.nvim": { "branch": "master", "commit": "1a08824835d7582457b67acbe23ca33487912a5e" },
"grug-far.nvim": { "branch": "main", "commit": "635e69adf3a714621bd0a289314bc23c5848babb" },
"helpview.nvim": { "branch": "main", "commit": "34be34afd0811dee17e6b0c46176d9140659fe8e" },
"image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" },
"image.nvim": { "branch": "master", "commit": "6ffafab2e98b5bda46bf227055aa84b90add8cdc" },
"img-clip.nvim": { "branch": "main", "commit": "28a32d811d69042f4fa5c3d5fa35571df2bc1623" },
"jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },

View file

@ -53,48 +53,44 @@ return {
ft = { "quarto" },
},
{
"vhyrro/luarocks.nvim",
priority = 1001, -- this plugin needs to run before anything else
opts = {
rocks = { "magick" },
},
},
-- image display
{
"3rd/image.nvim",
dependencies = { "luarocks.nvim", { "nvim-treesitter/nvim-treesitter", optional = true } },
cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed
config = function()
local integrations = {}
if vim.treesitter.language.get_lang("markdown") then
integrations["markdown"] = {
enabled = true,
clear_in_insert_mode = true,
download_remote_images = true,
version = false,
dependencies = {
{
"vhyrro/luarocks.nvim",
priority = 1001, -- this plugin needs to run before anything else
opts = {
rocks = { "magick" },
},
},
{ "nvim-treesitter/nvim-treesitter", optional = true },
},
opts = {
backend = "kitty",
editor_only_render_when_focused = true,
-- TODO: Check that this works without TS md parser, norg or typst installed
-- If errors go back to commit before 87691932 when this check was still here
integrations = {
markdown = {
only_render_image_at_cursor = true,
filetypes = { "markdown", "vimwiki", "quarto" },
}
end
if vim.treesitter.language.get_lang("norg") then
integrations["neorg"] = {
enabled = true,
clear_in_insert_mode = true,
download_remote_images = true,
},
neorg = {
only_render_image_at_cursor = true,
filetypes = { "norg" },
}
end
if next(integrations) ~= nil then -- only set up if we have at least 1 TS parser
require("image").setup({
backend = "kitty",
integrations = integrations,
})
vim.g.molten_image_provider = "image.nvim"
pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim")
end
},
typst = {
only_render_image_at_cursor = true,
},
},
},
config = function(_, opts)
require("image").setup(opts)
vim.g.molten_image_provider = "image.nvim"
pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim")
end,
ft = { "markdown", "vimwiki", "quarto", "norg", "python" },
ft = { "markdown", "vimwiki", "quarto", "norg", "typst", "python" },
priority = 60,
},
-- REPL work