diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index 90947db..3ee4183 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -126,9 +126,10 @@ local lspconfig = require("lspconfig") -- ensure python virtualenv is determined automatically on lsp start lspconfig.pyright.setup({ - on_attach = function(client, _) - local python_path, msg = require("util.pyenv").get_path(client.config.root_dir) - vim.notify(string.format("%s\n%s", msg, python_path)) + on_attach = function(client, bufnr) + on_attach(client, bufnr) + local python_path, msg = require("util").get_python_venv(client.config.root_dir) + vim.notify_once(string.format("[PYTHON VENV]\n%s", python_path)) client.config.settings.python.pythonPath = python_path end, }) diff --git a/nvim/.config/nvim/lua/util/init.lua b/nvim/.config/nvim/lua/util/init.lua index 89b2668..ce2e2aa 100644 --- a/nvim/.config/nvim/lua/util/init.lua +++ b/nvim/.config/nvim/lua/util/init.lua @@ -9,4 +9,8 @@ function T.is_available(plugin) return lazy_config_avail and lazy_config.plugins[plugin] ~= nil end +function T.get_python_venv(workspace) + return require("util.pyenv").get_path(workspace) +end + return T diff --git a/nvim/.config/nvim/lua/util/pyenv.lua b/nvim/.config/nvim/lua/util/pyenv.lua index 9e24b2d..8e250b5 100644 --- a/nvim/.config/nvim/lua/util/pyenv.lua +++ b/nvim/.config/nvim/lua/util/pyenv.lua @@ -22,8 +22,7 @@ T.get_path = function(workspace) -- Find and use virtualenv in workspace directory. for _, pattern in ipairs({ "*", ".*" }) do local match = vim.fn.glob(path.join(workspace, pattern, "pyvenv.cfg")) - local sep = path_sep() - local py = "bin" .. sep .. "python" + local py = "bin" .. path_sep() .. "python" if match ~= "" then match = string.gsub(match, "pyvenv.cfg", py) return match, string.format("venv base folder: %s", match)