Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editors/vscode): update VSCode extention to use project's language server #6132

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
Empty file removed editors/vscode/.prettierrc
Empty file.
45 changes: 41 additions & 4 deletions editors/vscode/client/extension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { promises as fsPromises } from 'node:fs';

import {
commands,
ConfigurationTarget,
Expand Down Expand Up @@ -90,10 +92,45 @@ export async function activate(context: ExtensionContext) {
const outputChannel = window.createOutputChannel(outputChannelName);
const traceOutputChannel = window.createOutputChannel(traceOutputChannelName);

const ext = process.platform === 'win32' ? '.exe' : '';
// NOTE: The `./target/release` path is aligned with the path defined in .github/workflows/release_vscode.yml
const command = process.env.SERVER_PATH_DEV ??
join(context.extensionPath, `./target/release/oxc_language_server${ext}`);
async function findBinary(): Promise<string> {
const cfg = workspace.getConfiguration('oxc');

let bin = cfg.get<string>('binPath', '');
if (bin) {
try {
await fsPromises.access(bin);
return bin;
} catch {}
}

const workspaceFolders = workspace.workspaceFolders;
if (workspaceFolders) {
try {
return await Promise.any(
workspaceFolders.map(async (folder) => {
const binPath = join(
folder.uri.fsPath,
'node_modules',
'.bin',
'oxc_language_server',
);

await fsPromises.access(binPath);
shulaoda marked this conversation as resolved.
Show resolved Hide resolved
return binPath;
}),
);
} catch {}
}

const ext = process.platform === 'win32' ? '.exe' : '';
// NOTE: The `./target/release` path is aligned with the path defined in .github/workflows/release_vscode.yml
return (
process.env.SERVER_PATH_DEV ??
join(context.extensionPath, `./target/release/oxc_language_server${ext}`)
);
}

const command = await findBinary();
const run: Executable = {
command: command!,
options: {
Expand Down
4 changes: 2 additions & 2 deletions editors/vscode/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"lib": ["ES2020"],
"target": "es2021",
"lib": ["ES2021"],
"outDir": "dist",
"rootDir": "client",
"sourceMap": true,
Expand Down