Skip to content

Commit 9792cd5

Browse files
committed
feat: set program language with settings.json
1 parent db51f74 commit 9792cd5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/extension.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// Import the module and reference it with the alias vscode in your code below
33
import * as vscode from "vscode";
44
import { setupStatusBar } from "./statusbar/status";
5-
import { evalEditor } from "./commands/evalEditor";
65
import { registerAllCommands } from "./commands";
76
import { activateLspClient, deactivateLspClient } from "./lsp/client";
87
import { LanguageClient } from "vscode-languageclient/node";
8+
import { canonicaliseLocation } from "./utils/misc";
9+
import config from "./utils/config";
910

1011
// TODO: Don't expose this object directly, create an interface via a wrapper class
1112
export let client: LanguageClient;
@@ -25,6 +26,21 @@ export function activate(context: vscode.ExtensionContext) {
2526
const info = context.globalState.get("info") ?? {};
2627

2728
client.sendRequest("source/publishInfo", info);
29+
30+
// TODO: Prompt the user to make this folder the default, and then set back to the config store.
31+
32+
// Update user's workspace settings to associate .js to Source
33+
const workspaceFolder = canonicaliseLocation(config.workspaceFolder);
34+
if (
35+
vscode.workspace.workspaceFolders
36+
?.map((wf) => wf.uri.fsPath)
37+
.includes(workspaceFolder)
38+
) {
39+
const workspaceConfig = vscode.workspace.getConfiguration();
40+
workspaceConfig.update("files.associations", {
41+
"*.js": "source",
42+
});
43+
}
2844
}
2945

3046
// This method is called when your extension is deactivated

src/utils/editor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export class Editor {
5050
self.assessmentName = assessmentName;
5151
self.questionId = questionId;
5252

53-
// TODO: Prompt the user to make this folder the default, and then set back to the config store.
5453
const workspaceFolder = canonicaliseLocation(config.workspaceFolder);
5554

5655
const filePath = path.join(

0 commit comments

Comments
 (0)