From 4697e09472d6d592def770a3863b3425fa4bf3dc Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 16:10:41 +0200 Subject: [PATCH] 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. --- nvim/.config/nvim/lua/plugins/config/lsp.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index d4e42a7..3138473 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -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, })