nvim: Split python venv fetching into multiple

Now we can either fetch the python venv basefolder
(`require('core.util').get_python_venv_basefolder()`) or specifically
the python binary contained within (`.get_python_bin()`).

Additionally, the venv result should be cached for the duration of using
nvim so that we only have to fetch it once, regardless of how many
modules require it.
This commit is contained in:
Marty Oehme 2024-06-16 16:44:02 +02:00
parent 4f5445cc0e
commit 0bac43eb91
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 24 additions and 10 deletions

View file

@ -167,7 +167,7 @@ local python_path
lspconfig.basedpyright.setup({
on_attach = function(client, bufnr)
if python_path == nil then
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir))
end
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
client.config.settings.python = {} or client.config.settings.python
@ -179,7 +179,7 @@ lspconfig.ruff_lsp.setup({
on_attach = function(client, bufnr)
on_attach(client, bufnr)
if python_path == nil then
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir))
end
client.config.settings.python = {} or client.config.settings.python
client.config.settings.python.pythonPath = python_path