nvim-lua / wishlist

A public catalogue of Lua plugins Neovim users would like to see exist
MIT License
235 stars 0 forks source link

organized view of rendered math equations #51

Open userrand opened 1 year ago

userrand commented 1 year ago

What? Summarize the plugin you'd like to see exist. In a few sentences, what's your idea?

Ability to navigate through rendered equations, select and display multiple equations. The equations can be given using an external program or rendered in certain terminals, maybe like in this repository https://github.com/3rd/image.nvim/ that i did not try.

Why? What should this plugin provide? What problems does it solve?

latex code can be difficult to visualise

Potential existing implementations: Are there any existing plugins (Lua, Vimscript, or remote) that come close to your idea?

The popup of https://github.com/jbyuki/nabla.nvim comes close but I would prefer html of pdf

*Potential pitfalls:*

Are there any challenges you're aware of to making the plugin you're proposing?

The plugin might need to use external software due to the inability or difficulty to view images in terminal.

benlubas commented 5 months ago

something like this?

https://github.com/nvim-neorg/neorg/assets/56943754/d5f8e015-2cb3-4497-985d-ab9dca7f761a

userrand commented 5 months ago

@benlubas Yes although I think I also had in mind the ability to have a separate page just for equations, like being able to j/k up and down the rendered equations without the text around. That might have been what I had in mind when I wrote organized view in the title.

Did you implement that yourself ?

I saw that neorg got a pull request to add latex rendering and I think it got merged but I did not try it. You can see the development of that with https://github.com/nvim-neorg/neorg/pulls?q=is%3Apr+latex . It seems to require external dependencies. In particular , I am using the konsole terminal and I am not sure wheter that solution would work with konsole especially since I think I saw that there might be an issue (that I vaguely remember being fixable) with wezterm.

I decided to use doom Emacs instead as Emacs has image support like svg and png if I remember. In my emacs configuration I have code which creates an equation page with links that allow going from the equations page to the location of the equation in the original page. It might be a bit easier when looking for an equation than scrolling as the text is not there which can seem like noise at times.

There is work to make maybe the future version of org mode have a sort of asynchronous equation rendering which would make rendering of many equations a lot faster as I understand. There is also work, that might be added in the next version of org mode, to have live previews that give real time updated equation rendering as one types If I recall.

If anyone reading this is interested in using doom emacs for latex documents, note that it took me a while (maybe over a week not sure) to get the configuration how I wanted (although it could be faster for you, in particular if you want less than I did)

benlubas commented 5 months ago

That example is neorg. It's from an open PR to neorg.

It relies on image.nvim which can use kitty graphics protocol or uberzug++ (kitty is significantly better). I think konsole implements kitty graphics so you'd be fine.

I have no plans to make this render images not over the text, I don't see a point. I'd rather have it conceal the latex, but you could write your own plugin to do it very easily if you take a look at the way I implemented that.

userrand commented 5 months ago

@benlubas oh nice you are one of the contributors for latex rendering in neorg. Thank you for telling me about the possibility of latex rendering in neorg in case I did not know about it.

Konsole graphics support

Thank you for telling me about konsole graphics support. I searched for konsole graphics support and it does seem that there was a merged pull request according to https://invent.kde.org/utilities/konsole/-/merge_requests/594 but according to this reddit post https://www.reddit.com/r/kde/comments/1c6xftb/konsole_graphics_support_protocols/ there seems to be some issue with kitty support. At the moment I am ok with my emacs setup but thank you for telling me.

In case you are curious about the point of removing the text around the equations

As for having a seperate page without the text around the equations, I am not asking you to adapt the code for that functionality (I already implemented it in emacs) but in case you are curious about it, the point of it is basically the zen of reducing surrounding noise when searching for what you want.

You could use vimtex to search for previous equations but then you might have a bunch of context switches because of the jumps between equations and the surrounding text. Each context switch might mean needing to refocus on the cursor and/or the new equation for which you have to decide "no this is not the one" or "yes this is the one".

A lot of context switching might become tiring after a while and can slow someone down because of needing to reprocess the new environments.

This "equation view" page could be considered conceptually similar to wanting to conceal the latex code for an equation with its rendered image as it makes things simpler and easier to process which is why I prefer the rendered image over the code.