Commit graph

101 commits

Author SHA1 Message Date
Folke Lemaitre
e18e4f6452
fix(image): check to update on BufWinEnter and attach to buffer changes 2025-10-28 22:00:57 +01:00
Folke Lemaitre
4122143240
fix(image): increase timeout for querying the terminal. Closes #2344 2025-10-25 06:52:56 +02:00
Folke Lemaitre
7bf4175588
fix(image): detach image when reloading image file. Closes #2343 2025-10-25 06:43:26 +02:00
Folke Lemaitre
6f72643323
fix(image): only attach to a buffer once. Closes #2343 2025-10-24 23:30:38 +02:00
Folke Lemaitre
b029511abb
fix(image): let healthcheck wait till terminal detection is done 2025-10-24 07:38:39 +02:00
Folke Lemaitre
e93dcfdf39
fix(image): work around tmux extended-keys breaking TermResponse. Closes #2332
When tmux has extended-keys enabled, Neovim's TermResponse autocmd doesn't fire,
causing terminal response sequences to leak as literal text into buffers.

Workaround: Detect this configuration and query tmux directly for the terminal
name using `tmux display-message -p "#{client_termname}"` instead of sending
escape sequences.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 06:59:17 +02:00
Daniel Wennberg
90227af497
fix(image): skip \usepackage in comments and body (#2325)
## Description

Here are some small and hopefully uncontroversial tweaks to package
extraction from LaTeX preambles:

* Don't consider anything in comments
* Make sure that the extracted names are actually the arguments of
`\usepackage` and not some other macro on the same line
* Stop looking for packages at `\begin{document}`, where the preamble
ends and the body of the document begins (you can't load packages after
this, so any `\usepackage` beyond this point is content, not code. Also
saves a huge amount of work in large documents.)

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-23 11:14:32 +02:00
Folke Lemaitre
6c7ddae887
fix(image.terminal): do only terminal detection for now. Closes #2323 2025-10-23 07:02:17 +02:00
Folke Lemaitre
c1737d866e
feat(win): all existing snacks windows for all plugins now honor vim.o.winborder. Defaults to rounded if not set. 2025-10-22 23:06:35 +02:00
Folke Lemaitre
43261baf87
fix(image): detect kitty image protocol through terminal capability request. Closes #1695 2025-10-22 16:56:26 +02:00
Folke Lemaitre
92a08cece7
fix(image): work-around for sha256 not allowed to be a Blob 2025-10-21 23:39:36 +02:00
Folke Lemaitre
2c56e10b1d
feat(image): added support for base64 encoded images in url. Closes #2304 2025-10-21 22:59:36 +02:00
phanium
5173e96f33
fix(image): ENOENT on preview (#2301)
After cb6bf052, occationally I get this error when attach snacks.image
in fzf-lua previewer

vim.schedule callback: runtime/lua/vim/fs.lua:737:
ENOENT: no such file or directory:
/home/phan/.cache/nvim/snacks/image/56bd7d4f-img.shields.io-badge-Made-with-Lua-blueviolet.svg.data
stack traceback:
    [C]: in function 'error'
    runtime/lua/vim/fs.lua:737: in function 'rm'
    snacks.nvim/lua/snacks/image/convert.lua:66: in function 'on_error'
    snacks.nvim/lua/snacks/image/convert.lua:340: in function 'on_step'
snacks.nvim/lua/snacks/image/convert.lua:434: in function
<snacks.nvim/lua/snacks/image/convert.lua:433>
2025-10-21 14:46:27 +02:00
Sassan Haradji
9df47bce6a
feat(image): add icns support (#2120)
## Description

Add support for icns using sips

## Screenshots

<img width="708" height="910" alt="image"
src="https://github.com/user-attachments/assets/9ca85b23-e020-4b05-9aeb-6d40666d71b6"
/>

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-21 08:37:14 +02:00
Tod Morrison
1c3f15cb54
fix(image): correct render fallback to handle "editor" relative position (#2297)
PR #2296 had the conditionals in the wrong order and with an "or"
instead of an "and". This should finally fix the issue and pass
stylelua.

## Description

The correct condition for correcting the off-by-one is:
```
    if
      (Snacks.config.styles.snacks_image.relative ~= "editor")
      and ((vim.o.showtabline == 2) or (vim.o.showtabline == 1 and vim.fn.tabpagenr("$") > 1))
    then
```
This patch gets the conditional in the right order
2025-10-21 07:36:13 +02:00
Tod Morrison
c552cea131
fix(image): correct render fallback to handle "editor" relative position (#2296)
In PR 1560, @phanen reported an additional case that was not handled by
that fix when the style is set to `relative = "editor"`. This new patch
adds a check to handle that case.

## Description ##

This patch adds a check for `Snacks.config.styles.snacks_image.relative
~= "editor"` to the conditional in render_fallback that handles the
off-by-one error. The previous patch fixed the relative = "cursor" case,
but introduced a regression in the relative = "editor" case.
2025-10-21 07:01:50 +02:00
Folke Lemaitre
30687d195b
feat(image): added clear fun. Closes #1394 2025-10-20 18:27:14 +02:00
Folke Lemaitre
19ff343a16
style: format 2025-10-20 15:29:47 +02:00
Ori Perry
3f0fe34308
feat(image): allow specifying a page number for inlined pdfs (#1806)
## Description
Allow specifying a page number for pdfs inside of markdown.

This is done by adding "#page=<page-number>" to the file name. This is
same way it is done in obsidian (as discussed in
https://forum.obsidian.md/t/link-to-the-exact-page-of-and-external-pdf-file/2111)

The parsing of the page info should probably be done way before the
conversion, but this was the best I could with my limited time.
I'm pretty new to lua, and this codebase, so this might not be the best
code, but I hope it at least helps :D
## Related Issue(s)

  - Fixes #1805
2025-10-20 15:05:53 +02:00
Tod Morrison
441bdcd210
fix(image): correct off by one issue in render fallback (#1560)
Fix off-by-one issue in render_fallback when a tabline is shown (e.g.
with plugins like bufferline.nvim).

## Description

When a tabline is used/shown, the positioning in render_fallback is off
by one. This change checks whether a tabline would be shown and uses the
correct math for that case and, otherwise, works as before.

## Related Issue(s)

  - Fixes #1557
2025-10-20 14:59:33 +02:00
Jay Z
ef59af0ffc
fix(image): hover close in insert mode (#2215)
## Description

I'm not 100% sure if this is a bug or if it was intentional, but the
`return` seems to have been lost from a previous refactor
e35d6cd4 (diff-ff9a4f8a621887c466394f755193cc78a5e69e0e2e86f4e668662e1434d3611eL878).

When an image displays using float or hover, the image can block the
text even in insert mode. This makes editing really hard. Adding the
`return` can close the hover in insert mode.

## Related Issue(s)

I couldn't find an issue created for this, but there is a discussion
about it https://github.com/folke/snacks.nvim/discussions/1777.

## Screenshots

Before the fix, the image shows in insert mode.
<img width="704" height="710" alt="image"
src="https://github.com/user-attachments/assets/224883d1-edbc-4f7a-8c1b-91ef00dbe21e"
/>

After the fix, the image stops showing in insert mode.
<img width="389" height="127" alt="image"
src="https://github.com/user-attachments/assets/d704d4f8-9259-4e5e-b7a9-954ea6e2a788"
/>
2025-10-19 12:04:44 +02:00
Peter Cardenas
cb6bf052da
fix(image): do not save remote image if fetch fails (#1915)
## Description

If fetching an image fails, when the buffer with the image is opened
again, the error message shown is for the `identify` command rather than
the `url` command. This is because the output of the `wget` or `curl`
command is saved to the file even if the fetching fails. Thus, when we
try to resolve it again, we think it's cached and read the file on the
`identify` step only to fail.

## Related Issue(s)

did not find any
2025-10-19 10:19:56 +02:00
phanium
758e64c18f
fix(image): set winblend=0 for floatwin when use unicode placeholders (#1615)
When `winblend > 1`
(8de1dc6923/src/nvim/highlight.c (L751)),
hover image is not shown (in kitty).

Reproduce: `nvim +'set winblend=10' docs/image.md +2`

I have a `vim.o.winblend = 20` in global config before floatwin created.
That's why I notice it.

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2025-10-19 10:14:25 +02:00
Folke Lemaitre
bc0630e43b
feat(image.inline): honor concealcursor and hide conceal when selecting lines. Closes #1478
Some checks failed
CI / ci (push) Failing after 0s
2025-03-01 23:37:02 +01:00
Folke Lemaitre
bc2ed15c41
fix(image): only show anchor icon for inline images shown on the lines below. Closes #1479 2025-03-01 22:58:56 +01:00
Folke Lemaitre
e55ae37beb
perf(image): async treesitter parsing for images 2025-03-01 17:33:53 +01:00
Folke Lemaitre
d9bb639fed
fix(image.inline): remove debug 2025-03-01 08:08:50 +01:00
Folke Lemaitre
6ea4fa72dc
feat(image): proper inline rendering of math expressions. Closes #1318. Closes #1454 2025-03-01 08:01:11 +01:00
Folke Lemaitre
1b63b1811c
fix(image.terminal): write queued terminal output on main 2025-02-24 11:27:39 +01:00
Folke Lemaitre
842605f072
fix(compat): properly detect async treesitter parsing 2025-02-24 10:28:22 +01:00
Folke Lemaitre
2b34c4dc05
fix(image.terminal): reset queue when timer runs 2025-02-23 08:13:00 +01:00
Folke Lemaitre
5fa93cb684
fix(image.placement): max width/height in cells is 297. Closes #1345
Some checks failed
CI / ci (push) Failing after 0s
2025-02-20 18:12:49 +01:00
Folke Lemaitre
e039139291
feat(image): configurable templates for math expressions. Closes #1338 2025-02-20 17:11:12 +01:00
Folke Lemaitre
1543a063fb
feat(image): allow disabling math rendering. Closes #1247 2025-02-20 11:56:56 +01:00
Folke Lemaitre
29c777a0a0
feat(image.doc): check for image.ignore in ts meta. See #1276 2025-02-20 11:14:24 +01:00
Folke Lemaitre
9aa8cbb803
fix(image): delay sending first image, to make ghostty happy. Closes #1333 2025-02-20 10:17:08 +01:00
Folke Lemaitre
7b7f42fb3b
perf(image.convert): identify during convert instead of calling identify afterwards 2025-02-20 07:28:50 +01:00
Folke Lemaitre
bc902f7032
feat(compat): added svim, a compatibility layer for Neovim. Closes #1321 2025-02-20 06:59:44 +01:00
Stefan Boca
4f8b9ebf71
fix(image.doc): crop inline typst equations properly (#1320)
Some checks failed
CI / ci (push) Failing after 0s
## Description

Tall inline typst equations were previously cropped too much vertically.
The change to the template now resize text frames to the bounding box of
their glyphs. See
https://typst.app/docs/reference/text/text/#parameters-top-edge for more
details.

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots
Before:

![image](https://github.com/user-attachments/assets/15ea02e2-7d10-43bb-8d4f-fc51013c8a20)
After:

![image](https://github.com/user-attachments/assets/70de42d9-4b29-4333-a908-6be4729baa8a)
2025-02-19 23:41:29 +01:00
Folke Lemaitre
31e21ccef8
fix(image): move assertion for src/content. See #1276 2025-02-19 23:40:18 +01:00
Folke Lemaitre
bde3adddc7
feat(image.doc): allow configuring the header for latex / typst inline in the document. Closes #1303 2025-02-19 23:06:51 +01:00
Folke Lemaitre
e2d9941896
perf(image): no need to run identify before convert for local files 2025-02-19 22:56:11 +01:00
Folke Lemaitre
6d1cda4a6d
fix(image): let text conversion continue on errors. See #1303 2025-02-19 22:56:11 +01:00
Folke Lemaitre
f45dd6c44c
fix(image): remove some default latex packages 2025-02-19 22:56:11 +01:00
Folke Lemaitre
bf01460e6d
feat(image): use search dirs to resolve file from both cwd and dirname of file. Closes #1305 2025-02-19 18:43:37 +01:00
Folke Lemaitre
d389c5df14
feat(image): better health checks 2025-02-19 17:16:05 +01:00
Folke Lemaitre
684666f643
feat(image): conceal option for inline rendering (disabled by default) 2025-02-19 15:41:16 +01:00
Folke Lemaitre
65f89e2d6f
feat(image.doc): allow setting image.src with #set!. Closes #1276 2025-02-19 15:17:33 +01:00
Folke Lemaitre
e146a66cb7
fix(image): better cell size calculation for non-HDPI displays 2025-02-19 15:07:28 +01:00
Folke Lemaitre
b052eb9372
feat(image): allow customizing font size for math expressions 2025-02-19 13:15:42 +01:00