nvim: Lazy load molten plugin
This commit is contained in:
parent
1e2246aa51
commit
ebd247e765
2 changed files with 13 additions and 31 deletions
|
|
@ -87,8 +87,12 @@ return {
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
require("image").setup(opts)
|
require("image").setup(opts)
|
||||||
vim.g.molten_image_provider = "image.nvim"
|
-- if Molten is running, we directly inject the option
|
||||||
|
if vim.fn.exists("MoltenDeinit") > 0 then
|
||||||
pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim")
|
pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim")
|
||||||
|
else
|
||||||
|
vim.g.molten_image_provider = "image.nvim"
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
ft = { "markdown", "vimwiki", "quarto", "norg", "typst", "python" },
|
ft = { "markdown", "vimwiki", "quarto", "norg", "typst", "python" },
|
||||||
priority = 60,
|
priority = 60,
|
||||||
|
|
@ -101,7 +105,7 @@ return {
|
||||||
{ "3rd/image.nvim", optional = true },
|
{ "3rd/image.nvim", optional = true },
|
||||||
},
|
},
|
||||||
build = ":UpdateRemotePlugins",
|
build = ":UpdateRemotePlugins",
|
||||||
config = function()
|
init = function()
|
||||||
vim.g.molten_image_provider = vim.g.molten_image_provider or "wezterm"
|
vim.g.molten_image_provider = vim.g.molten_image_provider or "wezterm"
|
||||||
vim.g.molten_auto_open_output = false
|
vim.g.molten_auto_open_output = false
|
||||||
vim.g.molten_virt_text_output = true
|
vim.g.molten_virt_text_output = true
|
||||||
|
|
@ -126,7 +130,7 @@ return {
|
||||||
map(
|
map(
|
||||||
"x",
|
"x",
|
||||||
"<localleader>c",
|
"<localleader>c",
|
||||||
":<C-u>MoltenEvaluateVisual<cr>",
|
":<C-u>MoltenEvaluateVisual<cr>gv",
|
||||||
{ desc = "evaluate visual", silent = true }
|
{ desc = "evaluate visual", silent = true }
|
||||||
)
|
)
|
||||||
map(
|
map(
|
||||||
|
|
@ -189,33 +193,6 @@ return {
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>vn", ":MoltenInfo<cr>" },
|
{ "<leader>vn", ":MoltenInfo<cr>" },
|
||||||
},
|
},
|
||||||
cmd = {
|
|
||||||
"JupyterStart",
|
|
||||||
"MoltenInfo",
|
|
||||||
"MoltenInit",
|
|
||||||
"MoltenDeinit",
|
|
||||||
"MoltenGoto",
|
|
||||||
"MoltenNext",
|
|
||||||
"MoltenPrev",
|
|
||||||
"MoltenEvaluateLine",
|
|
||||||
"MoltenEvaluateVisual",
|
|
||||||
"MoltenEvaluateOperator",
|
|
||||||
"MoltenEvaluateArgument",
|
|
||||||
"MoltenReevaluateCell",
|
|
||||||
"MoltenDelete",
|
|
||||||
"MoltenShowOutput",
|
|
||||||
"MoltenHideOutput",
|
|
||||||
"MoltenEnterOutput",
|
|
||||||
"MoltenInterrupt",
|
|
||||||
"MoltenOpenInBrowser",
|
|
||||||
"MoltenImagePopup",
|
|
||||||
"MoltenRestart",
|
|
||||||
"MoltenSave",
|
|
||||||
"MoltenLoad",
|
|
||||||
"MoltenExportOutput",
|
|
||||||
"MoltenImportOutput",
|
|
||||||
},
|
|
||||||
lazy = false,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Edit code blocks in md/quarto using whatever language is
|
-- Edit code blocks in md/quarto using whatever language is
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ return {
|
||||||
cond = true,
|
cond = true,
|
||||||
dependencies = { { "nvim-tree/nvim-web-devicons", config = true } },
|
dependencies = { { "nvim-tree/nvim-web-devicons", config = true } },
|
||||||
config = function()
|
config = function()
|
||||||
|
-- TODO: Should grab ft directly from molten lazy spec
|
||||||
|
local molten_ft = { "markdown", "rmd", "quarto" }
|
||||||
local has_pynvim = -1
|
local has_pynvim = -1
|
||||||
-- if molten exists, is initialized and connected to a kernel
|
-- if molten exists, is initialized and connected to a kernel
|
||||||
-- show it in the statusline
|
-- show it in the statusline
|
||||||
|
|
@ -13,6 +15,9 @@ return {
|
||||||
if has_pynvim == 0 then
|
if has_pynvim == 0 then
|
||||||
return ""
|
return ""
|
||||||
elseif has_pynvim == 1 then
|
elseif has_pynvim == 1 then
|
||||||
|
if molten_ft[vim.bo.filetype] == nil then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
local status_ok, res = pcall(function()
|
local status_ok, res = pcall(function()
|
||||||
return require("molten.status").kernels() ~= ""
|
return require("molten.status").kernels() ~= ""
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue