Skip to content

Commit 8f7860b

Browse files
committed
remove option
1 parent 57d9c7a commit 8f7860b

2 files changed

Lines changed: 17 additions & 28 deletions

File tree

client/src/extension.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from "path";
2+
import * as fs from "fs";
23
import {
34
workspace,
45
ExtensionContext,
@@ -91,29 +92,26 @@ export function activate(context: ExtensionContext) {
9192
"rescript",
9293
);
9394

94-
function createExperimentalLanguageClient() {
95-
const binaryPathFromNodeModules = Uri.joinPath(
96-
context.extensionUri,
97-
"node_modules",
98-
".bin",
99-
"rescript-language-server",
100-
).fsPath;
95+
const useExperimentalServer = workspace
96+
.getConfiguration("rescript")
97+
.get<string | null>("experimentalServerPath", null);
10198

102-
const userServerPath = workspace
103-
.getConfiguration("rescript")
104-
.get<string | null>("experimentalServerPath", null);
105-
106-
const binaryPath = userServerPath
107-
? userServerPath
108-
: binaryPathFromNodeModules;
99+
function createExperimentalLanguageClient(serverPath: string) {
100+
if (!fs.existsSync(serverPath)) {
101+
const message = `The experimental server is enabled with \`experimentalServerPath\`, but no language server was found at ${serverPath}. See the instructions for using the experimental server in [ADD_LINK_TO_DOCS_HERE].`;
102+
outputChannel.appendLine(message);
103+
window.showErrorMessage(message);
104+
outputChannel.show();
105+
throw new Error(message);
106+
}
109107

110108
let serverOptions: ServerOptions = {
111109
run: {
112-
command: binaryPath,
110+
command: serverPath,
113111
transport: TransportKind.stdio,
114112
},
115113
debug: {
116-
command: binaryPath,
114+
command: serverPath,
117115
transport: TransportKind.stdio,
118116
},
119117
};
@@ -194,12 +192,8 @@ export function activate(context: ExtensionContext) {
194192
}
195193

196194
function createClient() {
197-
const useExperimentalServer = workspace
198-
.getConfiguration("rescript")
199-
.get<boolean>("useExperimentalServer", false);
200-
201-
return useExperimentalServer
202-
? createExperimentalLanguageClient()
195+
return useExperimentalServer != null
196+
? createExperimentalLanguageClient(useExperimentalServer)
203197
: createLanguageClient();
204198
}
205199

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,13 @@
158158
"type": "object",
159159
"title": "ReScript",
160160
"properties": {
161-
"rescript.useExperimentalServer": {
162-
"type": "boolean",
163-
"default": false,
164-
"description": "Whether to use the experimental ReScript language server (OCaml implementation) instead of the stable one (Node.js implementation). You can switch back and forth without affecting your project or settings."
165-
},
166161
"rescript.experimentalServerPath": {
167162
"type": [
168163
"string",
169164
"null"
170165
],
171166
"default": null,
172-
"description": "Path to the experimental ReScript language server binary. You can set this if you want to use a custom-built version of the experimental server or if the extension is unable to automatically locate the server binary in your system."
167+
"description": "Path to the experimental ReScript language server binary."
173168
},
174169
"rescript.settings.askToStartBuild": {
175170
"scope": "language-overridable",

0 commit comments

Comments
 (0)