Skip to content
Merged
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
18 changes: 18 additions & 0 deletions editors/vscode/client/VSCodeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class VSCodeConfig implements VSCodeConfigInterface {
private _trace!: TraceLevel;
private _binPathOxlint: string | undefined;
private _binPathOxfmt: string | undefined;
private _binPathTsGoLint: string | undefined;
private _nodePath: string | undefined;
private _requireConfig!: boolean;

Expand All @@ -27,6 +28,7 @@ export class VSCodeConfig implements VSCodeConfigInterface {
this._trace = this.configuration.get<TraceLevel>("trace.server") || "off";
this._binPathOxlint = binPathOxlint;
this._binPathOxfmt = this.configuration.get<string>("path.oxfmt");
this._binPathTsGoLint = this.configuration.get<string>("path.tsgolint");
this._nodePath = this.configuration.get<string>("path.node");
this._requireConfig = this.configuration.get<boolean>("requireConfig") ?? false;
}
Expand Down Expand Up @@ -67,6 +69,15 @@ export class VSCodeConfig implements VSCodeConfigInterface {
return this.configuration.update("path.oxfmt", value);
}

get binPathTsGoLint(): string | undefined {
return this._binPathTsGoLint;
}

updateBinPathTsGoLint(value: string | undefined): PromiseLike<void> {
this._binPathTsGoLint = value;
return this.configuration.update("path.tsgolint", value);
}

get nodePath(): string | undefined {
return this._nodePath;
}
Expand Down Expand Up @@ -112,6 +123,13 @@ interface VSCodeConfigInterface {
*/
binPathOxlint: string | undefined;

/**
* Path to the `tsgolint` binary
* `oxc.path.tsgolint`
* @default undefined
*/
binPathTsGoLint: string | undefined;

/**
* Path to Node.js
* `oxc.path.node`
Expand Down
6 changes: 5 additions & 1 deletion editors/vscode/client/tools/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ export default class LinterTool implements ToolInterface {

context.subscriptions.push(restartCommand, toggleEnable, applyAllFixesFile);

const run: Executable = runExecutable(binaryPath, configService.vsCodeConfig.nodePath);
const run: Executable = runExecutable(
binaryPath,
configService.vsCodeConfig.nodePath,
configService.vsCodeConfig.binPathTsGoLint,
);
const serverOptions: ServerOptions = {
run,
debug: run,
Expand Down
5 changes: 4 additions & 1 deletion editors/vscode/client/tools/lsp_helper.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { LogOutputChannel, window } from "vscode";
import { Executable, MessageType, ShowMessageParams } from "vscode-languageclient/node";

export function runExecutable(path: string, nodePath?: string): Executable {
export function runExecutable(path: string, nodePath?: string, tsgolintPath?: string): Executable {
const serverEnv: Record<string, string> = {
...process.env,
RUST_LOG: process.env.RUST_LOG || "info",
};
if (nodePath) {
serverEnv.PATH = `${nodePath}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`;
}
if (tsgolintPath) {
serverEnv.OXLINT_TSGOLINT_PATH = tsgolintPath;
}
const isNode = path.endsWith(".js") || path.endsWith(".cjs") || path.endsWith(".mjs");

return isNode
Expand Down
5 changes: 5 additions & 0 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@
"scope": "window",
"markdownDescription": "Path to an Oxc formatter binary. Will be used by the language server instead of the bundled one."
},
"oxc.path.tsgolint": {
"type": "string",
"scope": "window",
"markdownDescription": "Path to an Oxc tsgolint binary. Will be used by the language server instead of the bundled one."
},
"oxc.path.node": {
"type": "string",
"scope": "window",
Expand Down
4 changes: 2 additions & 2 deletions editors/vscode/tests/ConfigService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const conf = workspace.getConfiguration('oxc');

suite('ConfigService', () => {
setup(async () => {
const keys = ['path.server', 'path.oxlint', 'path.oxfmt'];
const keys = ['path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint'];

await Promise.all(keys.map(key => conf.update(key, undefined)));
});

teardown(async () => {
const keys = ['path.server', 'path.oxlint', 'path.oxfmt'];
const keys = ['path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint'];

await Promise.all(keys.map(key => conf.update(key, undefined)));
});
Expand Down
5 changes: 4 additions & 1 deletion editors/vscode/tests/VSCodeConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { testSingleFolderMode } from './test-helpers.js';
const conf = workspace.getConfiguration('oxc');

suite('VSCodeConfig', () => {
const keys = ['enable', 'requireConfig', 'trace.server', 'path.server', 'path.oxlint', 'path.oxfmt', 'path.node'];
const keys = ['enable', 'requireConfig', 'trace.server', 'path.server', 'path.oxlint', 'path.oxfmt', 'path.tsgolint', 'path.node'];
setup(async () => {
await Promise.all(keys.map(key => conf.update(key, undefined)));
});
Expand All @@ -23,6 +23,7 @@ suite('VSCodeConfig', () => {
strictEqual(config.trace, 'off');
strictEqual(config.binPathOxlint, '');
strictEqual(config.binPathOxfmt, '');
strictEqual(config.binPathTsGoLint, '');
strictEqual(config.nodePath, '');
});

Expand All @@ -42,6 +43,7 @@ suite('VSCodeConfig', () => {
config.updateTrace('messages'),
config.updateBinPathOxlint('./binary'),
config.updateBinPathOxfmt('./formatter'),
config.updateBinPathTsGoLint('./tsgolint'),
config.updateNodePath('./node'),
]);

Expand All @@ -52,6 +54,7 @@ suite('VSCodeConfig', () => {
strictEqual(wsConfig.get('trace.server'), 'messages');
strictEqual(wsConfig.get('path.oxlint'), './binary');
strictEqual(wsConfig.get('path.oxfmt'), './formatter');
strictEqual(wsConfig.get('path.tsgolint'), './tsgolint');
strictEqual(wsConfig.get('path.node'), './node');
});
});
Loading