Package: neopyter
JupyterLab + NeovimA JupyterLab extension.A Neovim pluginHow does it work?TheJupyter lab's frontend plugin provides RPC service which expose functions ofJupyter lab, Jupyterlab server
forward these RPC service by TCP Server.Neovims plugin connect to TCP Server and call RPC service when receive events
fromNeovimviaautocmd. In the end,Neopytercan controlJuppyter lab.Neopytercan implement more ability likejupynium.nvim, but better performance.ScreenshotsCompletionCell MagicLine MagicInstallationRequirements📔JupyterLab >= 4.0.0✌️ Neovim >= 9.0👍nvim-lua/plenary.nvimJupyterLab ExtensionTo install the jupyterlab extension, execute:pipinstallneopyterTo remove the extension, execute:pipuninstallneopyterNeovim pluginWith 💤lazy.nvim:{"SUSTech-data/neopyter",opts={auto_attach=true,-- your jupyter host + neopyter portremote_address="127.0.0.1:9001",file_pattern={"*.ju.*"},},}Quick StartOpen JupyterLabjupyter lab, there is a sidebar namedNeopyter, which display neopyter ip+portOpen a*.ju.pyfile in neovim[Optional] ifauto_attachisfalse, you can connect jupyterlab manually via:Neopyter connect 127.0.0.1:9001Now you can type# %%in Neovim to create a code cell.You'll see everything you type below that will be synchronised in the browserAvailable Vim CommandsServer:Neopyter connect [remote 'ip:port'], e.g.:Neopyter command 127.0.0.1:9001, connectJupyter labmanually:Neopyter disconnect:Neopyter statusalias to:checkhealth neopytercurrentlySync:Neopyter sync current, make sync current*.ju.*file with the currently open*.ipynb:Neopyter sync [filename], e.g.:Neopyter sync main.ipynbRun:Neopyter run current, same asRun>Run Selected Cell and Do not Advancemenu inJupyter lab:Neopyter run allAbove, same asRun>Run All Above Selected Cellmenu inJupyter lab:Neopyter run allBelow, same asRun>Run Selected Cell and All Belowmenu inJupyter lab:Neopyter run all, same asRun>Run All Cellsmenu inJupyter labKernel:Neopyter kernel restart, same asKernel>Restart Kernelmenu inJupyter lab:Neopyter kernel restartRunAll, same asKernel>Restart Kernel and Run All Cellsmenu inJupyter labJupyter:Neopyter execute [command_id] [args], executeJupyter lab'scommanddirectly, e.g.:Neopyter execute notebook:export-to-format {"format":"html"}APINeopyterprovides rich lua APIsJupyter LabNeopyter execute ...<->require("neopyter.jupyter").jupyterlab:execute_command(...)All APIs see:lua =require("neopyter.jupyter.jupyterlab").__injected_methodsNotebook:Neopyter run current<->require("neopyter.jupyter").notebook:run_selected_cell():Neopyter run allAbove<->require("neopyter.jupyter").notebook:run_all_above():Neopyter run allBelow<->require("neopyter.jupyter").notebook:run_all_below()All APIs see:lua =require("neopyter.jupyter.notebook").__injected_methodsFeaturesNeovimFull syncPartial syncScroll view automaticallyActivate cell automaticallySave notebook automaticallyCompletionMagic completion itemPath completion itemDisable others?Kernel manageRestart kernelRestart kernel and run allRun cellRun selected cellRun all above selected cellRun selected cell and all belowRun all cellSyncSet synchronized.ipynbmanuallyNotebook managerOpen corresponding notebook if existsSync with untitled notebook defaultClose notebook when buffer unloadJupyter LabSettingsTcp server host/port settingsStatusSidebarDisplayip:portDisplay client infoPerformanceRewriteRpcClient, support async rpc requestvim.rpcrequestandvim.rpcnotifyDocumentAPI DocumentAcknowledgesjupynium.nvim: Selenium-automated Jupyter Notebook that is synchronised with NeoVim in real-time.ContributingJupyterLab ExtensionDevelopment installNote: You will needNodeJSto build the extension package. Recommend usepnpm# Clone the repo to your local environment# Change directory to the current project directory# Install package in development modepipinstall-e"."# Link your development version of the extension with JupyterLabjupyterlabextensiondevelop.--overwrite# Rebuild extension Typescript source after making changespnpmbuildYou can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.# Watch the source directory in one terminal, automatically rebuilding when neededpnpmwatch# Run JupyterLab in another terminaljupyterlabWith the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).By default, thepnpm buildcommand generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:jupyterlabbuild--minimize=FalseDevelopment uninstallpipuninstallneopyterIn development mode, you will also need to remove the symlink created byjupyter labextension developcommand. To find its location, you can runjupyter labextension listto figure out where thelabextensionsfolder is located. Then you can remove the symlink namedneopyterwithin that folder.Testing the extensionFrontend testsThis extension is usingJestfor JavaScript code testing.To execute them, execute:pnpminstall
pnpmtestIntegration testsThis extension usesPlaywrightfor the integration tests (aka user level tests).
More precisely, the JupyterLab helperGalatais used to handle testing the extension in JupyterLab.More information are provided within theui-testsREADME.Packaging the extensionSeeRELEASE