Skip to content

Commit 96b1112

Browse files
authored
feat: add syntaxHighlightingOnly setting (#85)
Adds a `jaclang-extension.syntaxHighlightingOnly` boolean setting (default false). When enabled, the extension skips EnvManager initialization and LSP startup, and the Jac-specific menu/context commands (run, debug, restart language server, serve, lintfix) are hidden via `when` clauses. Useful for environments where users only need syntax highlighting and do not have a Jac runtime installed.
1 parent 99bdc72 commit 96b1112

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"type": "boolean",
4242
"default": false,
4343
"description": "Enable developer mode to use experimental language server features"
44+
},
45+
"jaclang-extension.syntaxHighlightingOnly": {
46+
"type": "boolean",
47+
"default": false,
48+
"description": "Enable syntax highlighting only. Disables the Jac language server and environment selection (no type checking, diagnostics, go-to-definition, hover, or completion)."
4449
}
4550
}
4651
},
@@ -91,30 +96,30 @@
9196
{
9297
"command": "jaclang-extension.runCurrentFile",
9398
"group": "navigation@0",
94-
"when": "resourceLangId == jac"
99+
"when": "resourceLangId == jac && !config.jaclang-extension.syntaxHighlightingOnly"
95100
},
96101
{
97102
"command": "jaclang-extension.debugCurrentFile",
98103
"group": "navigation@1",
99-
"when": "resourceLangId == jac"
104+
"when": "resourceLangId == jac && !config.jaclang-extension.syntaxHighlightingOnly"
100105
}
101106
],
102107
"editor/title": [
103108
{
104109
"command": "jaclang-extension.restartLanguageServer",
105110
"group": "navigation@98",
106-
"when": "resourceLangId == jac && config.jaclang-extension.developerMode"
111+
"when": "resourceLangId == jac && config.jaclang-extension.developerMode && !config.jaclang-extension.syntaxHighlightingOnly"
107112
},
108113
{
109114
"command": "jaclang-extension.serveCurrentFile",
110115
"group": "navigation@99",
111-
"when": "resourceLangId == jac && config.jaclang-extension.showServeCommand"
116+
"when": "resourceLangId == jac && config.jaclang-extension.showServeCommand && !config.jaclang-extension.syntaxHighlightingOnly"
112117
}
113118
],
114119
"editor/context": [
115120
{
116121
"command": "jac.lintfixFormat",
117-
"when": "resourceLangId == jac",
122+
"when": "resourceLangId == jac && !config.jaclang-extension.syntaxHighlightingOnly",
118123
"group": "1_modification"
119124
}
120125
],

src/extension.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export function getEnvManager(): EnvManager | undefined {
1616
return envManager;
1717
}
1818

19+
export function isSyntaxHighlightingOnly(): boolean {
20+
return vscode.workspace
21+
.getConfiguration("jaclang-extension")
22+
.get<boolean>("syntaxHighlightingOnly", false);
23+
}
24+
1925
// Create and start LSP Manager if not already running
2026
export async function createAndStartLsp(
2127
envManager: EnvManager,
@@ -37,18 +43,24 @@ export async function activate(context: vscode.ExtensionContext) {
3743
try {
3844
envManager = new EnvManager(context);
3945
registerAllCommands(context, envManager);
40-
await envManager.init();
46+
47+
const highlightOnly = isSyntaxHighlightingOnly();
48+
if (!highlightOnly) {
49+
await envManager.init();
50+
}
4151

4252
setupVisualDebuggerWebview(context);
4353

44-
const jacPath = envManager.getJacPath();
45-
const isJacAvailable = await validateJacExecutable(jacPath); // Check if Jac is available before starting LSP
54+
if (!highlightOnly) {
55+
const jacPath = envManager.getJacPath();
56+
const isJacAvailable = await validateJacExecutable(jacPath); // Check if Jac is available before starting LSP
4657

47-
if (isJacAvailable) {
48-
try {
49-
await createAndStartLsp(envManager, context);
50-
} catch (error) {
51-
console.error("LSP failed to start during activation:", error);
58+
if (isJacAvailable) {
59+
try {
60+
await createAndStartLsp(envManager, context);
61+
} catch (error) {
62+
console.error("LSP failed to start during activation:", error);
63+
}
5264
}
5365
}
5466

@@ -63,4 +75,4 @@ export async function activate(context: vscode.ExtensionContext) {
6375

6476
export function deactivate(): Thenable<void> | undefined {
6577
return lspManager?.stop();
66-
}
78+
}

0 commit comments

Comments
 (0)