|
1 | 1 | import path from "path"; |
2 | | -import fs from "fs"; |
3 | 2 | import os from "os"; |
4 | 3 | import { performance as Perf } from "perf_hooks"; |
5 | 4 |
|
@@ -121,45 +120,21 @@ function getLspExecutables(workspaceFolder: vscode.WorkspaceFolder, env: NodeJS. |
121 | 120 | options: executableOptions, |
122 | 121 | }; |
123 | 122 | } else { |
124 | | - const args = []; |
125 | | - const workspacePath = workspaceFolder.uri.fsPath; |
126 | | - let command: string; |
127 | | - |
128 | | - if (serverPath.length > 0 && branch.length > 0) { |
129 | | - throw new Error( |
130 | | - 'Invalid configuration: "rubyLsp.serverPath" and "rubyLsp.branch" cannot both be set. Please unset one of them.', |
131 | | - ); |
132 | | - } |
133 | | - |
134 | | - if (serverPath.length > 0) { |
135 | | - const absoluteServerPath = path.isAbsolute(serverPath) ? serverPath : path.resolve(workspacePath, serverPath); |
136 | | - const exists = fs.existsSync(absoluteServerPath); |
137 | | - |
138 | | - if (exists) { |
139 | | - args.push("--path", absoluteServerPath); |
140 | | - const stat = fs.statSync(absoluteServerPath); |
141 | | - |
142 | | - if (stat.isDirectory()) { |
143 | | - command = os.platform() !== "win32" ? path.join(absoluteServerPath, "exe", "ruby-lsp") : "ruby-lsp"; |
144 | | - } else { |
145 | | - command = absoluteServerPath; |
146 | | - } |
147 | | - } else { |
148 | | - throw new Error( |
149 | | - `The configured rubyLsp.serverPath "${serverPath}" does not exist at "${absoluteServerPath}". `, |
150 | | - ); |
151 | | - } |
152 | | - } else { |
153 | | - command = |
154 | | - path.basename(workspacePath) === "ruby-lsp" && os.platform() !== "win32" |
155 | | - ? path.join(workspacePath, "exe", "ruby-lsp") |
156 | | - : "ruby-lsp"; |
157 | | - } |
| 123 | + const basePath = serverPath || workspaceFolder.uri.fsPath; |
| 124 | + const command = |
| 125 | + path.basename(basePath) === "ruby-lsp" && os.platform() !== "win32" |
| 126 | + ? path.join(basePath, "exe", "ruby-lsp") |
| 127 | + : "ruby-lsp"; |
158 | 128 |
|
| 129 | + const args = []; |
159 | 130 | if (branch.length > 0) { |
160 | 131 | args.push("--branch", branch); |
161 | 132 | } |
162 | 133 |
|
| 134 | + if (serverPath) { |
| 135 | + args.push("--lsp-path", serverPath); |
| 136 | + } |
| 137 | + |
163 | 138 | if (featureEnabled("launcher")) { |
164 | 139 | args.push("--use-launcher"); |
165 | 140 | } |
|
0 commit comments