Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ extension has the following configuration options:
the extension will disable the built-in VSCode JavaScript and TypeScript
language services, and will use the Deno Language Server (`deno lsp`) instead.
_boolean, default `false`_
- `deno.semanticHighlighting.enabled`: Controls if the extension provides semantic
tokens to VS Code. Disable this to use VS Code's built-in JavaScript and
TypeScript syntax highlighting instead. _boolean, default `true`_
- `deno.disablePaths`: Controls if the Deno Language Server is disabled for
specific paths of the workspace folder. Defaults to an empty list.
- `deno.enablePaths`: Controls if the Deno Language Server is enabled for only
Expand Down
5 changes: 3 additions & 2 deletions client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { DenoServerInfo } from "./server_info";

import * as dotenv from "dotenv";
import * as vscode from "vscode";
import { LanguageClient, ServerOptions } from "vscode-languageclient/node";
import { ServerOptions } from "vscode-languageclient/node";
import type {
Executable,
Location,
Expand All @@ -43,6 +43,7 @@ import * as fs from "fs";
import * as path from "path";
import * as process from "process";
import { semver } from "./semver";
import { DenoLanguageClient } from "./deno_language_client";

// deno-lint-ignore no-explicit-any
export type Callback = (...args: any[]) => unknown;
Expand Down Expand Up @@ -184,7 +185,7 @@ export function startLanguageServer(
options: { env, shell },
} as Executable,
};
const client = new LanguageClient(
const client = new DenoLanguageClient(
LANGUAGE_CLIENT_ID,
LANGUAGE_CLIENT_NAME,
serverOptions,
Expand Down
25 changes: 25 additions & 0 deletions client/src/deno_language_client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
LanguageClient,
type StaticFeature,
type DynamicFeature,
SemanticTokensRegistrationType,
} from "vscode-languageclient/node";

export class DenoLanguageClient extends LanguageClient {
override registerFeature(
feature: StaticFeature | DynamicFeature<unknown>,
): void {
const registrationType = (feature as {
registrationType?: { method: string };
}).registrationType;
const clientOptions = this.clientOptions.initializationOptions();
const semanticHighlightingIsEnabled = clientOptions.semanticHighlighting?.enabled ?? true;
const skipSemanticTokensRegistration = !semanticHighlightingIsEnabled && registrationType?.method === SemanticTokensRegistrationType.method;

if (skipSemanticTokensRegistration) {
return;
}

super.registerFeature(feature);
}
}
1 change: 1 addition & 0 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function handleConfigurationChange(event: vscode.ConfigurationChangeEvent) {
event.affectsConfiguration("deno.env") ||
event.affectsConfiguration("deno.envFile") ||
event.affectsConfiguration("deno.future") ||
event.affectsConfiguration("deno.semanticHighlighting.enabled") ||
event.affectsConfiguration("deno.internalInspect") ||
event.affectsConfiguration("deno.logFile") ||
event.affectsConfiguration("deno.path") ||
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@
false
]
},
"deno.semanticHighlighting.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "Controls if the extension provides semantic tokens for files it manages. Set to false to rely on the built-in VS Code JavaScript and TypeScript syntax highlighting instead. Requires restarting the Deno language server to take effect.",
"scope": "resource",
"examples": [
true,
false
]
},
"deno.cacheOnSave": {
"type": "boolean",
"default": true,
Expand Down