snacks.nvim icon indicating copy to clipboard operation
snacks.nvim copied to clipboard

bug: LaTeX rendering fails when = is on its own line in math block

Open junyixu opened this issue 1 month ago • 3 comments

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)

NVIM v0.11.4 Build type: RelWithDebInfo LuaJIT 2.1.1761727121 Run "nvim -V1 -v" for more info

Operating system/version

Archlinux

Describe the bug

When a LaTeX math block contains = on a standalone line, the image fails to render. Moving = to the same line as other content fixes the issue.

Steps To Reproduce

Not working:

$$
\begin{bmatrix}
1 \\ 2
\end{bmatrix}
=
\frac{1}{2}
\begin{bmatrix}
2 \\ 4
\end{bmatrix}
$$

Working:

$$
\begin{bmatrix}
1 \\ 2
\end{bmatrix} =
\frac{1}{2}
\begin{bmatrix}
2 \\ 4
\end{bmatrix}
$$

Expected Behavior

= on a standalone line,

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 = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})

junyixu avatar Nov 05 '25 12:11 junyixu

I don't do latex, so feel free to create a PR

folke avatar Nov 05 '25 13:11 folke

Likely related to how treesitter extracts the math content from the $$ block. When the = is on its own line, it may be creating a parsing boundary that causes the displayed equation node to be split or captured incorrectly.

junyixu avatar Nov 08 '25 12:11 junyixu

A possible workaround would be to add a preprocessing step that normalizes standalone operators on their own lines. Not sure

junyixu avatar Nov 08 '25 12:11 junyixu

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Dec 09 '25 02:12 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Dec 16 '25 02:12 github-actions[bot]