From 3b1a8748833c43efa526e00ff328702fc766876c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 16 Jun 2024 21:32:56 +0200 Subject: [PATCH] nvim: Open ipynb files as quarto files We can now open any ipynb file as if it were a quarto document by leveraging the `jupytext.nvim` extension which works in the background to convert everything. Will only work if `jupytext` program is actually installed on the machine. Allows normal editing of the file and will write any changes back to the original notebook on save and exit! --- nvim/.config/nvim/lazy-lock.json | 1 + .../nvim/lua/plugins/data_analysis.lua | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 1ed5022..5712d06 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -35,6 +35,7 @@ "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, + "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 90d04f7..803dae1 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -221,4 +221,27 @@ return { }, lazy = false, }, + + -- Open ipynb Jupyter notebooks as if they're quarto files + -- requires jupytext to be installed + { + "GCBallesteros/jupytext.nvim", + opts = { + style = "light", + custom_language_formatting = { + python = { + extension = "qmd", + style = "quarto", + force_ft = "quarto", + }, + r = { + extension = "qmd", + style = "quarto", + force_ft = "quarto", + }, + }, + }, + cond = vim.fn.executable("jupytext") == 1, -- only runs if imagemagick installed + lazy = false -- does not work in lazy mode + }, }