From 2cb76c711764057eb2c2e66b621ef44013d3dbf2 Mon Sep 17 00:00:00 2001 From: ayamir Date: Thu, 1 Jun 2023 16:25:17 +0800 Subject: [PATCH] fix: correct path for pylsp plugins on windows, close #778. (#779) Signed-off-by: ayamir --- lua/modules/configs/completion/lsp.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/modules/configs/completion/lsp.lua b/lua/modules/configs/completion/lsp.lua index 237342e54b..a8299a84cc 100644 --- a/lua/modules/configs/completion/lsp.lua +++ b/lua/modules/configs/completion/lsp.lua @@ -34,6 +34,8 @@ return function() }, }) + local is_win = require("core.global").is_windows + -- Additional plugins for pylsp mason_registry:on( "package:install:success", @@ -43,9 +45,12 @@ return function() end local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv" + local python = is_win and venv .. "/Scripts/python.exe" or venv .. "/bin/python" + local black = is_win and venv .. "/Scripts/black.exe" or venv .. "/bin/black" + local ruff = is_win and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff" require("plenary.job") :new({ - command = venv .. "/bin/python", + command = python, args = { "-m", "pip", @@ -59,10 +64,7 @@ return function() cwd = venv, env = { VIRTUAL_ENV = venv }, on_exit = function() - if - vim.fn.executable(venv .. "/bin/black") == 1 - and vim.fn.executable(venv .. "/bin/ruff") == 1 - then + if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then vim.notify( "Finished installing pylsp plugins", vim.log.levels.INFO,