mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(editors/vscode): update VSCode extention to use project's language server (#6132)
closes #3426
This commit is contained in:
parent
8729755baa
commit
1a5f293d9b
3 changed files with 43 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { promises as fsPromises } from 'node:fs';
|
||||
|
||||
import {
|
||||
commands,
|
||||
ConfigurationTarget,
|
||||
|
|
@ -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);
|
||||
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: {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2020",
|
||||
"lib": ["ES2020"],
|
||||
"target": "es2021",
|
||||
"lib": ["ES2021"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "client",
|
||||
"sourceMap": true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue