From ab5c5744ad09662265fbb3399867c8881443c2c7 Mon Sep 17 00:00:00 2001 From: Chenggou <115768501+chenggouA@users.noreply.github.com> Date: Sun, 27 Jul 2025 22:16:08 +0800 Subject: [PATCH] fix: use platform path separator for venv --- lua/uv/init.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lua/uv/init.lua b/lua/uv/init.lua index dd7e05d..a4acfc6 100644 --- a/lua/uv/init.lua +++ b/lua/uv/init.lua @@ -80,15 +80,16 @@ end -- Virtual environment activation function M.activate_venv(venv_path) - -- For Mac, run the source command to apply to the current shell - local command = "source " .. venv_path .. "/bin/activate" - -- Set environment variables for the current Neovim instance - vim.env.VIRTUAL_ENV = venv_path - vim.env.PATH = venv_path .. "/bin:" .. vim.env.PATH - -- Notify user - if M.config.notify_activate_venv then - vim.notify("Activated virtual environment: " .. venv_path, vim.log.levels.INFO) - end + local is_windows = package.config:sub(1, 1) == '\\' + local venv_dir = is_windows and 'Scripts' or 'bin' + local sep = is_windows and ';' or ':' + + vim.env.VIRTUAL_ENV = venv_path + vim.env.PATH = venv_path .. '/' .. venv_dir .. sep .. vim.env.PATH + + if M.config.notify_activate_venv then + vim.notify("Activated virtual environment: " .. venv_path, vim.log.levels.INFO) + end end -- Auto-activate the .venv if it exists at the project root