neorg
neorg copied to clipboard
feat(latex): async image rendering
https://github.com/nvim-neorg/neorg/assets/56943754/d5f8e015-2cb3-4497-985d-ab9dca7f761a
Brings many many improvements to the latex renderer:
- Images are created and show asynchronously using nvim-nio
- Creating images never blocks nvim, even with excessive amounts of images
- Images correctly position themselves in line (accounting for other virtual text, folds, etc.)
- Enable/Disable commands
- minimum length requirement to render. This allows you to type
$x$
and not have it render a massive disproportionate letterx
for no good reason - Better documentation
- Image caching
- Persistent images with auto update--before images would just disappear when you started typing
- Foreground color controlled by a highlight group
- this updates and rerenders on colorscheme change
- Default links to
Normal
- Debounced rendering so it waits for you to finish typing, this is just to avoid an (even more) excessive amount of temp images being created.
- Debouncing can make things look bad, it's completely configurable, default is 200ms, setting it to 10ms makes it near impossible to notice (I don't recommend setting it to less than this in case you're running a macro or something).
Unfortunately this clobbers all of the changes in #1372, but it improves on most of what's happening there I think. I started this work before that PR went up, and then I got stalled with school and other things.
TODO:
- [x] When images move, they flash. I know why that happens, I think I can fix it, but I don't consider it blocking for this PR
- [x] Switching buffers messes with things really heavily. All of the information that we store needs to be on a per-buffer level
- [x] Image.nvim doesn't automatically handle text concealing causing images to move
- fixed by https://github.com/3rd/image.nvim/pull/156
- [x] Other image.nvim issues/inconcitencies
- fixed by https://github.com/3rd/image.nvim/pull/159
- [x] image.nvim PRs need to be merged
Code generally looks great! I've managed to find another bug that may or may not be known: other virtual text seems to break positioning within the buffer (e.g. images generated by .image
). I assume this is a bug that needs fixing on image.nvim's side, right?
I don't see that behavior, and we definitely account for that in image nvim. Is your image nvim on latest from GitHub?
I'm on the latest stable luarocks release which I realized happens to be from 144 days ago :joy:, perhaps that's due for an update :sweat_smile:
I asked 3rd to cut a release, I think that triggers a luarocks build too, so you can try the rocks version again
Thanks for getting that release out, that's fixed now at least :)