Skip to content

Commit

Permalink
chore(vscode): improve dx (oxc-project#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY authored Nov 24, 2023
1 parent 6e81b3d commit 9897cab
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"args": ["--extensionDevelopmentPath=${workspaceFolder}/editors/vscode" ],
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/editors/vscode/dist/*.js"],
"preLaunchTask": "watch",
"env": {
"SERVER_PATH_DEV": "${workspaceRoot}/target/debug/oxc_vscode"
}
Expand Down
5 changes: 1 addition & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc-watch"
]
}
}
]
}
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions editors/vscode/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const enum OxcCommands {
ShowTraceOutputChannel = "oxc.showTraceOutputChannel"
};


let client: LanguageClient;


Expand Down Expand Up @@ -70,7 +69,8 @@ export async function activate(context: ExtensionContext) {
const traceOutputChannel = window.createOutputChannel(traceOutputChannelName);

const ext = process.platform === "win32" ? ".exe" : "";
const command = join(context.extensionPath, `./target/release/oxc_vscode${ext}`);
let serverPath = process.env.SERVER_PATH_DEV ?? `oxc_vscode${ext}`;
const command = join(serverPath);

// window.showInformationMessage(`oxc server path: ${command}`);

Expand Down
25 changes: 24 additions & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,35 @@
"title": "Show Trace Output Channel",
"category": "Oxc"
}
]
],
"configuration": {
"type": "object",
"title": "oxc",
"properties": {
"oxc-client.trace.server": {
"type": "string",
"scope": "window",
"enum": [
"off",
"messages",
"verbose"
],
"enumDescriptions": [
"No traces",
"Error only",
"Full log"
],
"default": "off",
"description": "Traces the communication between VS Code and the language server."
}
}
}
},
"scripts": {
"preinstall": "[ -f icon.png ] || curl https://raw.githubusercontent.com/Boshen/oxc-assets/main/logo-square.png --output icon.png",
"build": "pnpm run server:build:release && pnpm run compile && pnpm run package",
"compile": "esbuild client/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node --target=node16 --minify",
"watch": "pnpm run compile --watch",
"package": "vsce package --no-dependencies -o oxc_lsp.vsix",
"publish": "vsce publish --no-dependencies",
"install-extension": "code --install-extension oxc_lsp.vsix --force",
Expand Down
1 change: 1 addition & 0 deletions editors/vscode/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ rayon = { workspace = true }
ropey = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tower-lsp = { workspace = true, features = ["proposed"] }
log = "0.4.20"
4 changes: 3 additions & 1 deletion editors/vscode/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod options;
mod walk;

use crate::linter::{DiagnosticReport, ServerLinter};
use log::debug;
use std::collections::HashMap;
use std::fmt::Debug;
use std::path::PathBuf;
Expand Down Expand Up @@ -56,7 +57,7 @@ impl LanguageServer for Backend {
}

async fn initialized(&self, _: InitializedParams) {
self.client.log_message(MessageType::INFO, "oxc initialized.").await;
debug!("oxc initialized.");

if let Some(Some(root_uri)) = self.root_uri.get() {
self.server_linter.make_plugin(root_uri);
Expand All @@ -77,6 +78,7 @@ impl LanguageServer for Backend {
}

async fn did_save(&self, params: DidSaveTextDocumentParams) {
debug!("oxc server did save");
self.handle_file_update(params.text_document.uri).await;
}

Expand Down
4 changes: 2 additions & 2 deletions tasks/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ test = false
doctest = false

[dependencies]
console = "0.15.7"
console = "0.15.7"
oxc_syntax = { workspace = true, features = ["serde"] }

project-root = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
similar = "2.3.0"
similar = "2.3.0"

ureq = { workspace = true }
url = { workspace = true }

0 comments on commit 9897cab

Please sign in to comment.