snacks.nvim
snacks.nvim copied to clipboard
bug: image.nvim float preview does not auto resize LaTeX equations
Did you check docs and existing issues?
- [x] I have read all the snacks.nvim docs
- [x] I have updated the plugin to the latest version before submitting this issue
- [x] I have searched the existing issues of snacks.nvim
- [x] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
v0.10.4
Operating system/version
MacOS 14.5
Describe the bug
Latex Equations previewed with image.nvim float (hover) style previews do not properly scale, causing them to scale to their maximum height and width values (whichever is reached first).
This causes shorter equations to be absolutely massive on screen, as they are scaled to the max height before they can reach the max width. Setting the max height to 1 or 2 cells does work to get those equations under control, however, it causes the taller equations (Sum, Matricies, etc...) being scaled incredibly small.
The scaling error may be due to the way window scaling is implemented around line 216 of images/doc.lua
:
local loc = hover.img:state().loc
win.opts.width = loc.width
win.opts.height = loc.height
Unfortunately, I could not find a fix.
Steps To Reproduce
- Configure images.nvim to render with floating windows
- Open
*.tex
document - Move cursor over equation (something as simple as
$x$
will do the trick)
Expected Behavior
Floating equations to be autoscaled to the standard DPI, same as the inline images.
Repro
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
main = "nvim-treesitter.configs", -- Sets main module to use for opts
opts = {
ensure_installed = {
"latex",
},
},
},
{
"folke/snacks.nvim",
opts = {
image = {
---@class snacks.image.Config
enabled = true,
doc = {
-- enable image viewer for documents
-- a treesitter parser must be available for the enabled languages.
-- supported language injections: markdown, html
enabled = true,
-- render the image inline in the buffer
-- if your env doesn't support unicode placeholders, this will be disabled
-- takes precedence over `opts.float` on supported terminals
inline = false,
-- render the image in a floating window
-- only used if `opts.inline` is disabled
float = true,
max_width = 40,
max_height = 40,
},
},
},
},
}, -- add any other plugins here
},
})