Skip to content

Commit 602a31f

Browse files
committed
feat: set program language with settings.json
1 parent 2343c23 commit 602a31f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/extension.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { setupStatusBar } from "./statusbar/status";
66
import { registerAllCommands } from "./commands";
77
import { activateLspClient, deactivateLspClient } from "./lsp/client";
88
import { LanguageClient } from "vscode-languageclient/node";
9+
import { canonicaliseLocation } from "./utils/misc";
10+
import config from "./utils/config";
911

1012
// TODO: Don't expose this object directly, create an interface via a wrapper class
1113
export let client: LanguageClient;
@@ -34,6 +36,21 @@ export function activate(context: vscode.ExtensionContext) {
3436
"assets",
3537
"icon.svg",
3638
);
39+
40+
// TODO: Prompt the user to make this folder the default, and then set back to the config store.
41+
42+
// Update user's workspace settings to associate .js to Source
43+
const workspaceFolder = canonicaliseLocation(config.workspaceFolder);
44+
if (
45+
vscode.workspace.workspaceFolders
46+
?.map((wf) => wf.uri.fsPath)
47+
.includes(workspaceFolder)
48+
) {
49+
const workspaceConfig = vscode.workspace.getConfiguration();
50+
workspaceConfig.update("files.associations", {
51+
"*.js": "source",
52+
});
53+
}
3754
}
3855

3956
// 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)