From 4d33ba175f5457463ea8e84f6c7185280a9ef481 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Wed, 24 Sep 2025 10:08:58 +0200 Subject: [PATCH] Add jupyter notebook support for nvim --- modules/nvim.nix | 33 +++++++++++++++++++++++++++++++++ scripts/project-launcher.sh | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/nvim.nix b/modules/nvim.nix index ec45e5c..90ddedd 100644 --- a/modules/nvim.nix +++ b/modules/nvim.nix @@ -1,9 +1,19 @@ { pkgs, lib, ... }: +let + # Python with jupytext for notebook conversion + pythonWithJupytext = pkgs.python3.withPackages (ps: with ps; [ + jupytext + ]); +in + { programs.nixvim = { enable = true; defaultEditor = true; + + # Ensure jupytext is available for the jupytext.nvim plugin + extraPackages = [ pythonWithJupytext ]; # Global settings globals.mapleader = " "; @@ -189,6 +199,7 @@ vim-fugitive cmp-dictionary plenary-nvim # Required dependency for telescope + jupytext-nvim # Jupyter notebook viewing/editing support ]; # Keymaps @@ -307,6 +318,28 @@ }) ''} + -- Jupytext setup for Jupyter notebook viewing + require("jupytext").setup({ + -- Output format for notebooks (markdown with code cells) + style = "markdown", + output_extension = "md", -- Convert notebooks to markdown for viewing + force_ft = "markdown", -- Force markdown filetype for syntax highlighting + + -- Custom conversion parameters + custom = { + ["notebook_metadata_filter"] = "-all", -- Remove all notebook metadata + ["cell_metadata_filter"] = "-all", -- Remove all cell metadata + }, + }) + + -- Auto-convert .ipynb files when opening + vim.api.nvim_create_autocmd({"BufReadPre"}, { + pattern = {"*.ipynb"}, + callback = function() + vim.cmd("set ft=markdown") + end, + }) + -- Telescope setup for better file finding local telescope = require('telescope') local actions = require('telescope.actions') diff --git a/scripts/project-launcher.sh b/scripts/project-launcher.sh index 364b846..9bc811f 100755 --- a/scripts/project-launcher.sh +++ b/scripts/project-launcher.sh @@ -233,7 +233,7 @@ while IFS= read -r window_config; do tmux split-window -t "$SESSION_NAME:$WINDOW_INDEX" -h -c "$WINDOW_PATH" tmux split-window -t "$SESSION_NAME:$WINDOW_INDEX.2" -v -c "$WINDOW_PATH" tmux select-pane -t "$SESSION_NAME:$WINDOW_INDEX.1" - tmux send-keys -t "$SESSION_NAME:$WINDOW_INDEX.1" "claude -c" + tmux send-keys -t "$SESSION_NAME:$WINDOW_INDEX.1" "claude" C-m WINDOW_INDEX=$((WINDOW_INDEX + 1)) fi