nvim: Ensure pythonPath setting always finds entry

LSP attachment would complain if it did not find an existing dict to
access in the `settings.python` section of the python lsp dictionaries.
This fixes that by creating an empty dict if nothing exists yet,
essentially functioning as null-check.
This commit is contained in:
Marty Oehme 2024-06-06 16:10:41 +02:00
parent b37650ac03
commit 4697e09472
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

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