magma-nvim
magma-nvim copied to clipboard
REQUEST: Variable explorer
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.
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.
I enthusiastically subscribe to this request.
@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?
@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.
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
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 ?