feat(nvim): added molten.nvim for jupyter-like behavior

This commit is contained in:
2025-05-15 13:10:52 +02:00
parent 37192374c3
commit 12435bcbd1
5 changed files with 179 additions and 112 deletions

View File

@@ -1,7 +1,7 @@
local options = { local options = {
base46 = { base46 = {
theme = "catppuccin", -- default theme theme = "chadracula-evondev", -- default theme
hl_add = {}, hl_add = {},
hl_override = {}, hl_override = {},
integrations = {}, integrations = {},
@@ -11,7 +11,7 @@ local options = {
}, },
}, },
transparency = true, transparency = true,
theme_toggle = { "catppuccin", "one_light" }, theme_toggle = { "chadracula-evondev", "one_light" },
}, },
ui = { ui = {

View File

@@ -34,7 +34,7 @@ return {
"zip", "zip",
"zipPlugin", "zipPlugin",
"tutor", "tutor",
"rplugin", -- "rplugin",
"syntax", "syntax",
"synmenu", "synmenu",
"optwin", "optwin",

View File

@@ -97,3 +97,22 @@ end, { desc = "Gitsigns Blame line" })
map("n", "<leader>td", function() map("n", "<leader>td", function()
require("gitsigns").toggle_deleted() require("gitsigns").toggle_deleted()
end, { desc = "Gitsigns Toggle deleted" }) end, { desc = "Gitsigns Toggle deleted" })
-- molten related mappings
map("n", "<localleader>ip", function()
local venv = os.getenv("VIRTUAL_ENV") or os.getenv("CONDA_PREFIX")
if venv ~= nil then
-- in the form of /home/ha5pls/.local/state/virtualenvs/VENV_NAME
venv = string.match(venv, "/.+/(.+)")
vim.cmd(("MoltenInit %s"):format(venv))
else
vim.cmd("MoltenInit python3")
end
end, { desc = "Initialize Molten for python3" })
map("n", "<leader>mi", ":MoltenInit<CR>")
map("n", "<leader>me", ":MoltenEvaluateOperator<CR>")
map("n", "<leader>rr", ":MoltenReevaluateCell<CR>")
map("v", "<leader>r", ":<C-u>MoltenEvaluateVisual<CR>gv")
map("n", "<leader>os", ":noautocmd MoltenEnterOutput<CR>")
map("n", "<leader>oh", ":MoltenHideOutput<CR>")
map("n", "<leader>md", ":MoltenDelete<CR>")

View File

@@ -31,3 +31,16 @@ vim.opt.relativenumber = true
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 4
vim.opt.expandtab = true vim.opt.expandtab = true
-- use prepared venv, mostly for molten
local enable_providers = {
"python3_provider",
-- and so on
}
for _, plugin in pairs(enable_providers) do
vim.g["loaded_" .. plugin] = nil
vim.cmd("runtime " .. plugin)
end
vim.g.python3_host_prog = vim.fn.expand(os.getenv("XDG_STATE_HOME") .. "/virtualenvs/neovim/bin/python3")

View File

@@ -105,6 +105,41 @@ return {
"godlygeek/tabular", "godlygeek/tabular",
-- ft = "vhdl", -- temporary solution, but I only need it for vhdl. To be replaced with a real formatter long-term -- ft = "vhdl", -- temporary solution, but I only need it for vhdl. To be replaced with a real formatter long-term
cmd = { "GTabularize", "Tabularize" }, cmd = { "GTabularize", "Tabularize" },
},
{
"benlubas/molten-nvim",
-- version = "^1.0.0", -- use version <2.0.0 to avoid breaking changes
dependencies = { "3rd/image.nvim" },
build = ":UpdateRemotePlugins",
init = function()
vim.g.molten_image_provider = "image.nvim"
vim.g.molten_use_border_highlights = true
end,
-- lazy = false -- lazy = false
}, },
{
-- see the image.nvim readme for more information about configuring this plugin
"3rd/image.nvim",
opts = {
backend = "kitty", -- whatever backend you would like to use
max_width = 100,
max_height = 12,
max_height_window_percentage = math.huge,
max_width_window_percentage = math.huge,
window_overlap_clear_enabled = true, -- toggles images when windows are overlapped
window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" },
integrations = {
markdown = {
enabled = true,
clear_in_insert_mode = false,
download_remote_images = true,
only_render_image_at_cursor = false,
only_render_image_at_cursor_mode = "popup",
floating_windows = false, -- if true, images will be rendered in floating markdown windows
filetypes = { "markdown", "vimwiki" }, -- markdown extensions (ie. quarto) can go here
},
}, -- do whatever you want with image.nvim's integrations
},
}
} }