dccsillag / magma-nvim

Interact with Jupyter from NeoVim.
GNU General Public License v3.0
1.03k stars 53 forks source link

Design Questions #20

Closed tzachar closed 3 years ago

tzachar commented 3 years ago

Hi there.

Im trying to understand some of the design choices, as Im having trouble with some of the current behaviour. To be more precise, why are you calling MagmaBuffer.clear_interface on every CursorMoved? I would expect this to only be called when the cursor exited a cell / entered a different cell. This causes an excess of ui redraws, and also make it difficult to properly place images using Kitty.

dccsillag commented 3 years ago

That's because on CursorMoved there is a chance that the output window should change its position (e.g., the cell has a new line). It seemed quite tricky to do some sort of output display update without clearing everything and starting over from scratch.

Doing this for the floating window seemed fairly cheap; as for images, not so much; so what I did (in the Ueberzug canvas) was to have add_image and clear only queue image add/remove operations, which are only done on present, where we do not do anything when the image is to be both hidden and shown.

tzachar commented 3 years ago

Ok, but I still have an issue. The kitty graphics protocol only support image placement where the cursor is. So, I have to move the cursor b4 positioning the image. But this results in a CursoreMoved event, which gets me into an infinite loop or jumped out of the cell and the image is removed. I need some way to tell magma to disable catching the CursorMoved events so I can update the display properly.

Any idea?

dccsillag commented 3 years ago

Well, Vim has :noautocmd. Try using that? That would ensure that no autocmds are triggered at all, not only Magma ones.

dccsillag commented 3 years ago

Actually, it looks like all you'd need to do is change the eventignore option, which is much easier to do from a remote plugin (via self.nvim.options["eventignore"]).

eventignore_save = self.nvim.options["eventignore"]
self.nvim.options["eventignore"] = "all"
# ... do stuff
self.nvim.options["eventignore"] = eventignore_save
tzachar commented 3 years ago

10x, it seems to work. Updated #16

Would appreciate you looking at it.

dccsillag commented 3 years ago

Great! Will review in a bit.