|
1 | 1 | local M = {} |
2 | 2 |
|
3 | 3 | M.setup = function() |
4 | | - local is_windows = require("core.global").is_windows |
5 | | - |
6 | 4 | local lsp_deps = require("core.settings").lsp_deps |
7 | 5 | local mason_registry = require("mason-registry") |
8 | 6 | local mason_lspconfig = require("mason-lspconfig") |
@@ -118,67 +116,6 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire |
118 | 116 | for _, pkg in ipairs(mason_registry.get_installed_package_names()) do |
119 | 117 | setup_lsp_for_package(pkg) |
120 | 118 | end |
121 | | - |
122 | | - -- Hook into Mason's package install event to install extra plugins for pylsp (black, ruff, rope), |
123 | | - -- then configure the installed package's LSP using setup_lsp_for_package. |
124 | | - mason_registry:on( |
125 | | - "package:install:success", |
126 | | - vim.schedule_wrap(function(pkg) |
127 | | - if pkg.name == "python-lsp-server" then |
128 | | - local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv" |
129 | | - local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python" |
130 | | - local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black" |
131 | | - local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff" |
132 | | - |
133 | | - require("plenary.job") |
134 | | - :new({ |
135 | | - command = python, |
136 | | - args = { |
137 | | - "-m", |
138 | | - "pip", |
139 | | - "install", |
140 | | - "-U", |
141 | | - "--disable-pip-version-check", |
142 | | - "python-lsp-black", |
143 | | - "python-lsp-ruff", |
144 | | - "pylsp-rope", |
145 | | - }, |
146 | | - cwd = venv, |
147 | | - env = { VIRTUAL_ENV = venv }, |
148 | | - on_exit = function() |
149 | | - if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then |
150 | | - vim.notify( |
151 | | - "Finished installing pylsp plugins", |
152 | | - vim.log.levels.INFO, |
153 | | - { title = "[lsp] Install Status" } |
154 | | - ) |
155 | | - else |
156 | | - vim.notify( |
157 | | - "Failed to install pylsp plugins. [Executable not found]", |
158 | | - vim.log.levels.ERROR, |
159 | | - { title = "[lsp] Install Failure" } |
160 | | - ) |
161 | | - end |
162 | | - end, |
163 | | - on_start = function() |
164 | | - vim.notify( |
165 | | - "Now installing pylsp plugins...", |
166 | | - vim.log.levels.INFO, |
167 | | - { title = "[lsp] Install Status", timeout = 6000 } |
168 | | - ) |
169 | | - end, |
170 | | - on_stderr = function(_, msg_stream) |
171 | | - if msg_stream then |
172 | | - vim.notify(msg_stream, vim.log.levels.ERROR, { title = "[lsp] Install Failure" }) |
173 | | - end |
174 | | - end, |
175 | | - }) |
176 | | - :start() |
177 | | - end |
178 | | - |
179 | | - setup_lsp_for_package(pkg) |
180 | | - end) |
181 | | - ) |
182 | 119 | end |
183 | 120 |
|
184 | 121 | return M |
0 commit comments