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

@@ -15,15 +15,15 @@ vim.filetype.add({
}) })
-- Hyprlang LSP -- Hyprlang LSP
autocmd({'BufEnter', 'BufWinEnter'}, { autocmd({'BufEnter', 'BufWinEnter'}, {
pattern = {"*.hl", "hypr*.conf"}, pattern = {"*.hl", "hypr*.conf"},
callback = function(event) callback = function(event)
print(string.format("starting hyprls for %s", vim.inspect(event))) print(string.format("starting hyprls for %s", vim.inspect(event)))
vim.lsp.start { vim.lsp.start {
name = "hyprlang", name = "hyprlang",
cmd = {"hyprls"}, cmd = {"hyprls"},
root_dir = vim.fn.getcwd(), root_dir = vim.fn.getcwd(),
} }
end end
}) })
vim.g.vscode_snippets_path = "~/.config/nvim/snippets" vim.g.vscode_snippets_path = "~/.config/nvim/snippets"
@@ -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

@@ -1,110 +1,145 @@
return { return {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
-- event = 'BufWritePre', -- uncomment for format on save -- event = 'BufWritePre', -- uncomment for format on save
config = function() config = function()
require "configs.conform" require "configs.conform"
end, end,
},
{
"neovim/nvim-lspconfig",
config = function()
require "nvchad.configs.lspconfig"
require "configs.lspconfig"
end, -- Override to setup mason-lspconfig
},
-- override plugin configs
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",
-- c/cpp stuff
"clangd",
"clang-format",
-- python
"pyright@1.1.351", -- newer versions have node skill issue
"autopep8",
-- latex/markdown stuff
"ltex-ls",
"bibtex-tidy",
-- shell
"shellcheck",
-- Hyprlang
"hyrpls",
-- hdl
"rust_hdl",
},
}, },
},
{ {
"nvim-treesitter/nvim-treesitter", "neovim/nvim-lspconfig",
opts = { config = function()
ensure_installed = { require "nvchad.configs.lspconfig"
"vim", require "configs.lspconfig"
"lua", end, -- Override to setup mason-lspconfig
"html",
"css",
"c",
"cpp",
"markdown",
"markdown_inline",
"yaml",
"python",
"latex",
"vhdl",
"hyprlang",
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
}, },
},
{ -- override plugin configs
"nvim-tree/nvim-tree.lua", {
opts = { "williamboman/mason.nvim",
git = { opts = {
enable = true, ensure_installed = {
}, -- lua stuff
renderer = { "lua-language-server",
highlight_git = true, "stylua",
icons = {
show = { -- c/cpp stuff
git = true, "clangd",
}, "clang-format",
-- python
"pyright@1.1.351", -- newer versions have node skill issue
"autopep8",
-- latex/markdown stuff
"ltex-ls",
"bibtex-tidy",
-- shell
"shellcheck",
-- Hyprlang
"hyrpls",
-- hdl
"rust_hdl",
},
}, },
},
}, },
},
{ {
"stevearc/conform.nvim", "nvim-treesitter/nvim-treesitter",
-- for users those who want auto-save conform + lazyloading! opts = {
event = "BufWritePre", ensure_installed = {
config = function() "vim",
require "configs.conform" "lua",
end, "html",
}, "css",
"c",
"cpp",
"markdown",
"markdown_inline",
"yaml",
"python",
"latex",
"vhdl",
"hyprlang",
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
},
},
{ {
"godlygeek/tabular", "nvim-tree/nvim-tree.lua",
-- ft = "vhdl", -- temporary solution, but I only need it for vhdl. To be replaced with a real formatter long-term opts = {
cmd = { "GTabularize", "Tabularize" }, git = {
-- lazy = false enable = true,
}, },
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
},
},
{
"stevearc/conform.nvim",
-- for users those who want auto-save conform + lazyloading!
event = "BufWritePre",
config = function()
require "configs.conform"
end,
},
{
"godlygeek/tabular",
-- ft = "vhdl", -- temporary solution, but I only need it for vhdl. To be replaced with a real formatter long-term
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
},
{
-- 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
},
}
} }