nvim: Add direct python env set utility function

Added a simple 'set python environment' function to directly set the
correct python binary and update the PATH for python.
This commit is contained in:
Marty Oehme 2024-06-16 17:41:18 +02:00
parent 0bac43eb91
commit 9dcd2f3d48
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 11 additions and 2 deletions

View file

@ -32,6 +32,15 @@ end
local function path_join(...)
return table.concat(vim.tbl_flatten({ ... }), "/")
end
function T.set_python_env(workspace)
local base = vim.fn.expand(require("core.util").get_python_venv_basefolder(workspace))
local p = vim.env.PATH or ""
if not base then
return
end
vim.g["python3_host_prog"] = vim.fn.expand(require("core.util").get_python_venv_bin())
vim.env.PATH = base .. "/bin:" .. p
end
function T.get_python_venv_bin(workspace)
local pyenv = T.get_python_venv_basefolder(workspace)
if not pyenv then

View file

@ -9,12 +9,12 @@ return {
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("core.util").set_python_env()
require("quarto").setup({
lspFeatures = {
enabled = true,
languages = { "r", "python", "julia", "bash" },
diagnostics = { enabled = false, triggers = { "BufWritePost" } },
completion = { enabled = true },
},
codeRunner = {
enabled = true,