virt_lines support
virt_lines poc

requires nvim 0.8.0+
A safe way to get inline visualization. The implementation is currently very simplistic. Enable with:
require"nabla".enable_virt()
Disable with:
require"nabla".disable_virt()
Note: enable_virt only supports the inline syntax which is $ .. $. Currently $$ .. $$ will likely throw an error.
TODO:
- [x] : colorization
- [ ] : update the annotations as you type
- [x] : support inline conceal as well, so that the preview is not shifted upwards.
Nice @jbyuki well done. I wonder if it would be possible to hide $..$ in like normal mode so the buffer will be more readable.
Conceal is added.
Great @jbyuki will try it out in few days. Thanks.
I had to chance to interact with math equation. Does the conceal only hides $? if so, sorry I mean't hiding everything between $.
Also it seems I need to call require"nabla".enable_virt() each time I introduce new changes. Maybe on switch to normal mode it could be called automatically?
I'm not the brightest, yes it makes more sense. Only hiding the $ will not make any difference...
New commits completely hides the equation. But still some work need to be for alignment.
Yes, we could add an autocommand which disable & enable nabla everytime the user enters normal mode.
🤣Not true, happens to the best of us.

So this is a quick test of a previous file I shared with current state.
https://gist.github.com/kkharji/39bf5e931534e45a3b7b6ed2ec478273
It seems to ignore spaces between latex element, mathbb key, unable to handle multiple $..$ at the same line and causing crazy amount of space, I'm guessing because the virtual position is relative and only account for $..$ block
Yeah, the code was just full of bugs. The alignement should now be correct. I'm not collapsing the formulas into a single character because otherwise we get issues with long warping lines and alignement of formulas.
Would it be possible to add toggle_virt() or virt_enabled status flag?
The latter would allow for conditional mappings akin to "show popup or refresh virtual text".
It's added. toggle_virt() and is_virt_enabled().
Im getting
E5108: Error executing lua /Users/skreli/.config/nvim/plugged/nabla.nvim/lua/nabla.lua:140: atte mpt to index local 'g' (a nil value)
@andreasusc
This is not normal. This indicates that the ascii generation failed but it should output an error instead. Could you tell what input/buffer content you used?
Hi, I'm getting the error above as well, seems like single-line expressions are causing the issue.
$$1$$
...
E5108: Error executing lua ...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:140: attempt to index local 'g' (a nil value)
stack traceback:
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:140: in function 'colorize_virt'
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:474: in function 'enable_virt'
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:571: in function 'toggle_virt'
[string ":lua"]:1: in main chunk
The above content will trigger the error on calling :lua require("nabla").toggle_virt(). On changing to inline expressions the error does not occur.
A similar error is triggered on popup():
$$1$$
...
E5108: Error executing lua ...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:51: attempt to index local 'g' (a nil value)
stack traceback:
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:51: in function 'colorize'
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:380: in function 'popup'
[string ":lua"]:1: in main chunk
however still displays the popup with nil as content

Hope this helps 😃
Actually for enable_virt(), it only supports the inline syntax which is $ .. $. I should be more clear about that.
EDIT: I will push a fix for that shortly.
https://gist.github.com/kkharji/39bf5e931534e45a3b7b6ed2ec478273
Hey. Thanks for this nice implementation. There were some typos in the file in the gist. I have fixed them and uploaded an edited version here: https://gist.github.com/krishnakumarg1984/9d311585d96d5f834f200d4163749bc8
would it be possible to ignore $$$$ or [ ] instead of erroring? so if you have a document which has both $$ and the other ones you could use virt_lines for the things which are supported yet?
How to remove spaces to align left?
@adoyle-h I have changed the defaults to align left.
It's still possible to align in the center with enable_virt({align_center=true}).
@jbyuki LGTM. Thank you. 👍
Good day :)
Whenever I use toggle_virt() to enable virt_lines the document automatically reset to nowrap. Is this the intended behavior? If not, are there any configs to turn it off?