nvim-neorg/neorg

Adding image support

3rd opened this issue · 10 comments

3rd commented

Issues

  • I have checked existing issues and there are no existing ones with the same request.

Feature description

Hey, I'm working on a hacky way to add (some) image support to Neovim, and I'm trying to write integration for Neorg. Looking at the spec and #14, I assume a simple query for a macro matching .image https://url would be enough, but I've hit the following problem.

URLs seem to be broken apart when inside a (tag_parameters (param)) and there's also an error in the tree:
image

What works:

  • .image test.png

What doesn't work:

  • .image https://example.com/test.png
  • .image /tmp/test.png
  • .image ./test.png

Thank you!

Help

Yes

Implementation help

I need help with figuring out how to retrieve the images and their target position from a Norg document.

vhyrro commented

Hey! This parser bug will probably stay for a week or two more because there are so many priorities clashing in the project (plus I'm away on holiday right now :p), so I think it's best if you focus on other integrations and I'll let you know when this is fixed. Thanks for considering adding neorg support in the first place!

Btw, a while back I made a fork of hologram attempting to add more features. The most notable is its support for essentially every image format, thanks to the use of the magick luarock which allows for translating other formats to png via imagemagick. Yes, that does require luarocks, but I thought you might be interested since you're working on a hologram rewrite and might want vast image support :)
The code for that is found here with info in the README, plus the important code snippet here. Maybe my code can be of use after all haha.

3rd commented

Wow, this is great, thank you so much!
Didn't even think about this option, it would save so much pain for cropping as well!

3rd commented

@vhyrro Just wanna say thanks again, added magick as well and it's great (although I had to monkey patch the rock).
This means all image formats and ueberzugpp are supported now.
I'll grab the Neorg query from your fork and get it up & running with test.png, that seems to work fine.
Did some optimizations to the kitty rendering and it's very fast even inside tmux now: https://gist.ro/magick.mp4

vhyrro commented

Super glad to hear!

3rd commented

Done, thank you so much for all your contributions!

norg.mp4
vhyrro commented

Sick!! Good stuff :D
I'll get to fixing that parser whenever I can

this feature seems awesome, and how is the things going ? can we display the image from a url in norg file in nvim ?

Any updates for showing url image?

3rd commented

Did a change now to consider whatever is on the same line after .image the url, hope it's good enough for now.

image-neorg-remote.mp4
vhyrro commented

The temporary fix is a godsend. Thanks a lot!! I'll let you know when the issue is actually fixed, lots of things to do in Neorg so I haven't had time to implement the V3 parser yet :)