Add jupyter notebook support for nvim

This commit is contained in:
Yan Lin 2025-09-24 10:08:58 +02:00
parent 7a8c546802
commit 4d33ba175f
2 changed files with 34 additions and 1 deletions

View file

@ -1,10 +1,20 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let
# Python with jupytext for notebook conversion
pythonWithJupytext = pkgs.python3.withPackages (ps: with ps; [
jupytext
]);
in
{ {
programs.nixvim = { programs.nixvim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
# Ensure jupytext is available for the jupytext.nvim plugin
extraPackages = [ pythonWithJupytext ];
# Global settings # Global settings
globals.mapleader = " "; globals.mapleader = " ";
@ -189,6 +199,7 @@
vim-fugitive vim-fugitive
cmp-dictionary cmp-dictionary
plenary-nvim # Required dependency for telescope plenary-nvim # Required dependency for telescope
jupytext-nvim # Jupyter notebook viewing/editing support
]; ];
# Keymaps # 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 -- Telescope setup for better file finding
local telescope = require('telescope') local telescope = require('telescope')
local actions = require('telescope.actions') local actions = require('telescope.actions')

View file

@ -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" -h -c "$WINDOW_PATH"
tmux split-window -t "$SESSION_NAME:$WINDOW_INDEX.2" -v -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 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)) WINDOW_INDEX=$((WINDOW_INDEX + 1))
fi fi