nvim: Turn image preview setting into switch
Can be toggled with `]sp` ([P]review images _everywhere_), or with `[sp` ([P]review images _only at cursor_).
This commit is contained in:
parent
b0ed357037
commit
7447cb3354
1 changed files with 12 additions and 6 deletions
|
|
@ -86,15 +86,21 @@ return {
|
||||||
vim.g.molten_image_provider = "image.nvim"
|
vim.g.molten_image_provider = "image.nvim"
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set("n", "<localleader>pi", function()
|
local prev_img_everywhere = function(state)
|
||||||
for k, v in pairs(opts.integrations) do
|
for _, integ in pairs(opts.integrations) do
|
||||||
if v["only_render_image_at_cursor"] ~= nil then
|
if integ["only_render_image_at_cursor"] ~= nil then
|
||||||
v["only_render_image_at_cursor"] = not v["only_render_image_at_cursor"]
|
integ["only_render_image_at_cursor"] = not state
|
||||||
end
|
end
|
||||||
print(k, v)
|
|
||||||
end
|
end
|
||||||
require("image").setup(opts)
|
require("image").setup(opts)
|
||||||
end, { desc = "toggle image rendering", silent = true })
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "]sp", function()
|
||||||
|
prev_img_everywhere(true)
|
||||||
|
end, { desc = "preview images everywhere", silent = true })
|
||||||
|
vim.keymap.set("n", "[sp", function()
|
||||||
|
prev_img_everywhere(false)
|
||||||
|
end, { desc = "preview images at cursor", silent = true })
|
||||||
end,
|
end,
|
||||||
ft = { "markdown", "vimwiki", "quarto", "norg", "typst", "python" },
|
ft = { "markdown", "vimwiki", "quarto", "norg", "typst", "python" },
|
||||||
priority = 60,
|
priority = 60,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue