benlubas / molten-nvim

A neovim plugin for interactively running code with the jupyter kernel. Fork of magma-nvim with improvements in image rendering, performance, and more
GNU General Public License v3.0
398 stars 23 forks source link

[Help] Creating new notebooks? #213

Closed GitSquared closed 23 hours ago

GitSquared commented 2 days ago

Thanks for the great plugin and the notebook setup guide!

I have a silly question: the guide focuses on editing an existing notebook, but how do you create a new one from scratch?

This might be better suited for the Quarto or Jupytext converter plugins but since you wrote the workflow guide here I thought I'd ask anyway.

With regular text files I can just create a new buffer, write it with the correct file extension and open it again to trigger all the treesitter and language server machinery and start writing code. With notebooks, since the jupytext parser needs a valid notebook file to begin with, it's a bit trickier.

So far I've found a "workaround" by keeping an empty notebook file generated from Jupyterlab with the bare-minimum internal JSON structure and just copy-pasting that to start a new one, but it's not a great xp.

Appreciate any tips! Thanks

benlubas commented 2 days ago

It's kinda crazy that this has never occurred to me. If I had to make a new one right now I'd probably make a quarto file, export it manually, and then just open the notebook file.

I'd imagine you could also create a command like :NewIpynb <path> or something that just creates a file with a the bare minimum json at that path and then edits the file.

but yeah, I've only ever had to edit other people's notebooks haha

GitSquared commented 2 days ago

I've only ever had to edit other people's notebooks haha

guess i'm on the other side of the food chain 😆

you could also create a command ... that just creates a file with a the bare minimum json at that path and then edits the file

Do you think that'd be a useful addition to the guide? I might take a stab at it and open a PR to suggest it.

benlubas commented 2 days ago

Yeah I'd definitely accept a PR with something like that!

GitSquared commented 1 day ago

There you go! Works well on my side.