magma-nvim icon indicating copy to clipboard operation
magma-nvim copied to clipboard

REQUEST: Variable explorer

Open codemeleon opened this issue 4 years ago • 6 comments

Hi,

I would like to see a variable explorer feature in your plugin. Please check https://www.reddit.com/r/vim/comments/hl0paq/finally_figured_out_how_to_work_in_vim_with/ for more detail.

Thank you.

codemeleon avatar Aug 19 '21 14:08 codemeleon

I previously thought that this would be impossible to do in a cross-language manner, since I thought it was not really part of the Jupyter protocol. However, I've just remembered that there is a section of the documentation which I had just glossed over, which is support for DAP and extensions for it: https://jupyter-client.readthedocs.io/en/stable/messaging.html#additions-to-the-dap

In particular, it looks like there is an inspectVariables and a richInspectVariables requests, which seem like exactly what we need for this.

So this is definetly possible.

dccsillag avatar Aug 19 '21 18:08 dccsillag

I enthusiastically subscribe to this request.

pfitzn avatar Oct 24 '22 19:10 pfitzn

@codemeleon @GoodGuyPat I know that it's been a long time, I'm not sure if you would still be interested in this, but I'm willing to take a shot at implementing it.

I'm thinking just a window that opens with a list of variable names and values, hitting enter on one would pop open more information.

Is there anything that I'm missing?

benlubas avatar Sep 29 '23 21:09 benlubas

@codemeleon @GoodGuyPat I know that it's been a long time, I'm not sure if you would still be interested in this, but I'm willing to take a shot at implementing it.

I'm thinking just a window that opens with a list of variable names and values, hitting enter on one would pop open more information.

Is there anything that I'm missing?

Hey! From my side, I am still very eager to see this happen! A panel with the output of the %whos ipython command would already be hella helpful, and the option of (as you mention) expand on the contents of those variables would be awesome.

Not sure to what extent it could be an useful base, but the Spyder plugin Variable Explorer does exactly that, and I suspect it to be where many of us are coming from with this requirement.

pfitzn avatar Sep 29 '23 22:09 pfitzn

So I didn't see this comment until just now, but I just spent the better part of 20 minutes looking at https://github.com/ipselium/cpyvke (the variable explorer linked in the reddit post) to see how it requests the variable info, and I got to the point where it seemed to be executing the code whos and i was so confused. and now it makes sense lol

But this is very doable now. I'm not sure if there's more variable information to gain from the method that dccsillag mentioned above, so I'm going to move forward with just the data returned from the whos command

benlubas avatar Sep 29 '23 22:09 benlubas

I have a very rough version of this working here: https://github.com/benlubas/magma-nvim/tree/variable_explorer

I'll note that's a branch off of my main branch which has a lot of other changes, so using it would require switching image providers to image.nvim.

https://github.com/dccsillag/magma-nvim/assets/56943754/a1939dd1-14d1-4788-a456-a3a9b32a0138

Current list of glaring issues that I need to fix:

  • [ ] the buffer isn't immediately placed when opening the window so there's some time after the initial opening where you just see a split of the current buffer. I plan to add some type of loading message
  • [ ] auto update doesn't work for certain types of code cells/output
  • [ ] auto update causes open output windows to be redrawn/flash
  • [ ] there is no highlighting, and I need to overhaul the way list and dict types (and similar) are displayed.

Is something like this what you had in mind @GoodGuyPat ?

benlubas avatar Oct 01 '23 16:10 benlubas