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:
parent
a94b1ccbb2
commit
1b4f73ae9b
2 changed files with 20 additions and 10 deletions
|
@ -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"
|
||||
|
@ -15,7 +16,7 @@ local startsession = function(file, args)
|
|||
|
||||
local path = require("core.util").get_python_venv_bin()
|
||||
if not path then
|
||||
return
|
||||
return
|
||||
end
|
||||
vim.g["python3_host_prog"] = path
|
||||
|
||||
|
@ -44,15 +45,18 @@ vim.api.nvim_create_user_command("JupyterStart", function()
|
|||
startsession(vim.b["sessionfile"] or default_buffer_session())
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_autocmd({"InsertEnter", "BufEnter"}, {
|
||||
callback = function()
|
||||
if vim.b["sessionfile"] == nil then
|
||||
local path = default_buffer_session()
|
||||
vim.b["sessionfile"] = path
|
||||
vim.schedule_wrap(startsession(path))
|
||||
end
|
||||
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
|
||||
local path = default_buffer_session()
|
||||
vim.b["sessionfile"] = path
|
||||
vim.schedule_wrap(startsession(path))
|
||||
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" } })
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue