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:
parent
0bac43eb91
commit
9dcd2f3d48
2 changed files with 11 additions and 2 deletions
|
@ -32,6 +32,15 @@ end
|
||||||
local function path_join(...)
|
local function path_join(...)
|
||||||
return table.concat(vim.tbl_flatten({ ... }), "/")
|
return table.concat(vim.tbl_flatten({ ... }), "/")
|
||||||
end
|
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)
|
function T.get_python_venv_bin(workspace)
|
||||||
local pyenv = T.get_python_venv_basefolder(workspace)
|
local pyenv = T.get_python_venv_basefolder(workspace)
|
||||||
if not pyenv then
|
if not pyenv then
|
||||||
|
|
|
@ -9,12 +9,12 @@ return {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
|
require("core.util").set_python_env()
|
||||||
|
|
||||||
require("quarto").setup({
|
require("quarto").setup({
|
||||||
lspFeatures = {
|
lspFeatures = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
languages = { "r", "python", "julia", "bash" },
|
languages = { "r", "python", "julia", "bash" },
|
||||||
diagnostics = { enabled = false, triggers = { "BufWritePost" } },
|
|
||||||
completion = { enabled = true },
|
|
||||||
},
|
},
|
||||||
codeRunner = {
|
codeRunner = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
|
|
Loading…
Reference in a new issue