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
32 changes: 32 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"dependencies": {
"dotenv": "^16.4.5",
"jsonc-parser": "^3.2.0",
"picomatch": "^4.0.2",
"semver": "7.5.2",
"vscode-languageclient": "^8.0.1"
},
"devDependencies": {
"@types/picomatch": "^3.0.2",
"@types/semver": "7.3.9",
"@types/vscode": "1.77.0",
"vscode-test": "^1.6.1"
Expand Down
5 changes: 4 additions & 1 deletion client/src/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as vscode from "vscode";
import { DenoExtensionContext, EnableSettings } from "./types";
import * as os from "os";
import * as path from "path";
import { isMatch } from "picomatch";

export interface WorkspaceEnabledInfo {
folder: vscode.WorkspaceFolder;
Expand Down Expand Up @@ -36,13 +37,15 @@ export function isPathEnabled(
)?.[1] ?? extensionContext.enableSettingsUnscoped ??
{ enable: null, enablePaths: null, disablePaths: [] };
const scopesWithDenoJson = extensionContext.scopesWithDenoJson ?? new Set();
if (isMatch(filePath, enableSettings.disablePaths)) return false;
for (const path of enableSettings.disablePaths) {
if (pathStartsWith(filePath, path)) {
return false;
}
}
if (enableSettings.enablePaths) {
return enableSettings.enablePaths.some((p) => pathStartsWith(filePath, p));
return isMatch(filePath, enableSettings.enablePaths) ||
enableSettings.enablePaths.some((path) => pathStartsWith(filePath, path));
}
if (enableSettings.enable != null) {
return enableSettings.enable;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
"type": "string"
},
"default": [],
"markdownDescription": "Disables the Deno Language Server for specific paths. This will leave the built in TypeScript/JavaScript language server enabled for those paths. Takes priority over `deno.enablePaths`.\n\n**Not recommended to be enabled in user settings.**",
"markdownDescription": "Disables the Deno Language Server for specific paths. This will leave the built in TypeScript/JavaScript language server enabled for those paths. Glob patterns are supported via picomatch. Takes priority over `deno.enablePaths`.\n\n**Not recommended to be enabled in user settings.**",
"scope": "resource",
"examples": [
[
Expand All @@ -228,7 +228,7 @@
"type": "string"
},
"default": null,
"markdownDescription": "Enables the Deno Language Server for specific paths, instead of for the whole workspace folder. This will disable the built in TypeScript/JavaScript language server for those paths.\n\nWhen a value is set, the value of `\"deno.enable\"` is ignored.\n\nThe workspace folder is used as the base for the supplied paths. If for example you have all your Deno code in `worker` path in your workspace, you can add an item with the value of `./worker`, and the Deno will only provide diagnostics for the files within `worker` or any of its sub paths.\n\n**Not recommended to be enabled in user settings.**",
"markdownDescription": "Enables the Deno Language Server for specific paths, instead of for the whole workspace folder. This will disable the built in TypeScript/JavaScript language server for those paths. Glob patterns are supported via picomatch.\n\nWhen a value is set, the value of `\"deno.enable\"` is ignored.\n\nThe workspace folder is used as the base for the supplied paths. If for example you have all your Deno code in `worker` path in your workspace, you can add an item with the value of `./worker`, and the Deno will only provide diagnostics for the files within `worker` or any of its sub paths.\n\n**Not recommended to be enabled in user settings.**",
"scope": "resource",
"examples": [
[
Expand Down
34 changes: 34 additions & 0 deletions typescript-deno-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions typescript-deno-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"vscode": "^1.77.0"
},
"devDependencies": {
"@types/picomatch": "^3.0.2",
"typescript": "^5.0.2"
},
"dependencies": {
"picomatch": "^4.0.2"
}
}
9 changes: 6 additions & 3 deletions typescript-deno-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as process from "process";
import * as os from "os";
import { setImmediate } from "timers";
import * as util from "util";
import { isMatch } from "picomatch";

/** Extract the return type from a maybe function. */
// deno-lint-ignore no-explicit-any
Expand Down Expand Up @@ -66,15 +67,17 @@ class Plugin implements ts.server.PluginModule {
)?.[1] ?? pluginSettings.enableSettingsUnscoped ??
{ enable: null, enablePaths: null, disablePaths: [] };
const scopesWithDenoJson = pluginSettings.scopesWithDenoJson ?? [];
if (isMatch(fileName, enableSettings.disablePaths)) return false;
for (const path of enableSettings.disablePaths) {
if (pathStartsWith(fileName, path)) {
return false;
}
}
if (enableSettings.enablePaths) {
return enableSettings.enablePaths.some((path) =>
pathStartsWith(fileName, path)
);
return isMatch(fileName, enableSettings.enablePaths) ||
enableSettings.enablePaths.some((path) =>
pathStartsWith(fileName, path)
);
}
if (enableSettings.enable != null) {
return enableSettings.enable;
Expand Down