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:
parent
b37650ac03
commit
4697e09472
1 changed files with 2 additions and 0 deletions
|
@ -168,6 +168,7 @@ lspconfig.pyright.setup({
|
||||||
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
|
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
|
||||||
end
|
end
|
||||||
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
-- 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
|
client.config.settings.python.pythonPath = python_path
|
||||||
on_attach(client, bufnr)
|
on_attach(client, bufnr)
|
||||||
end,
|
end,
|
||||||
|
@ -178,6 +179,7 @@ lspconfig.ruff_lsp.setup({
|
||||||
if python_path == nil then
|
if python_path == nil then
|
||||||
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
|
python_path, _ = require("core.util").get_python_venv(client.config.root_dir)
|
||||||
end
|
end
|
||||||
|
client.config.settings.python = {} or client.config.settings.python
|
||||||
client.config.settings.python.pythonPath = python_path
|
client.config.settings.python.pythonPath = python_path
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue