nvim: Do not establish quarto molten session on open

We now disable the automatic establishing of quarto molten sessions
(using the virtual environment provided python interpreter) as soon as
the file is opened since it can have some negative side-effects and also
slows down quarto file opening.
Instead, use the `JupyterStart` command to establish a jupyter session
in the correct environment and initialize a molten session.

The behaviour can be re-enabled with
`vim.g.quarto_auto_init_molten_session = true`.
This commit is contained in:
Marty Oehme 2024-07-24 14:13:01 +02:00
parent a94b1ccbb2
commit 1b4f73ae9b
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 20 additions and 10 deletions

View file

@ -1,3 +1,4 @@
local default_buffer_session = function()
local buffer_path = vim.api.nvim_buf_get_name(0) or vim.fn.tempname()
local temp_path = vim.fn.stdpath("run") .. "/molten-sessions" .. buffer_path .. ".json"
@ -44,6 +45,7 @@ vim.api.nvim_create_user_command("JupyterStart", function()
startsession(vim.b["sessionfile"] or default_buffer_session())
end, {})
if vim.g.quarto_auto_init_molten_session then
vim.api.nvim_create_autocmd({ "InsertEnter", "BufEnter" }, {
callback = function()
if vim.b["sessionfile"] == nil then
@ -53,6 +55,8 @@ vim.api.nvim_create_autocmd({"InsertEnter", "BufEnter"}, {
end
end,
})
end
-- -- -- TODO find better way to enable lsp key mappings for quarto buffers
-- -- local prefix = require("which-key").register
-- -- prefix({ ["<localleader>l"] = { name = "+lsp" } })

View file

@ -1,3 +1,9 @@
-- Change (personal) plugin options
-- mainly intended for things I have not packaged as plugin but may
-- require options to be set.
vim.g.quarto_auto_init_molten_session = false
-- Change (Neo)Vim default options
local default_builtins_disabled = { "netrw", "netrwPlugin" }
local disable_builtins = function(builtins)
for _, plugin in pairs(builtins) do