Skip to content
Merged
Changes from 2 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
20 changes: 13 additions & 7 deletions src/oxc.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
use std::{env, fs, path::Path};
use zed_extension_api::{
self as zed,
self as zed, LanguageServerId, Result,
serde_json::{self, Value},
settings::LspSettings,
LanguageServerId, Result,
};

// the general expected server path (excluded for windows)
Comment thread
camc314 marked this conversation as resolved.
const SERVER_PATH: &str = "node_modules/oxlint/bin/oxc_language_server";
const PACKAGE_NAME: &str = "oxlint";
const FALLBACK_SERVER_PATH: &str = "./node_modules/.bin/oxc_language_server";

// fallback to the wrapper script
const FALLBACK_SERVER_PATH: &str = if cfg!(windows) {
Comment thread
Sysix marked this conversation as resolved.
Outdated
"./node_modules/.bin/oxc_language_server.CMD"
} else {
"./node_modules/.bin/oxc_language_server"
};
Comment thread
Sysix marked this conversation as resolved.
Outdated
const PACKAGE_NAME: &str = "oxlint";
const OXC_CONFIG_PATHS: &[&str] = &[".oxlintrc.json"];

struct OxcExtension;
Expand Down Expand Up @@ -37,7 +42,8 @@ impl OxcExtension {
|| !f["devDependencies"][PACKAGE_NAME].is_null()
});

if server_package_exists {
// windows needs the `.CMD` file, which is only inside `node_modules/.bin`.
Comment thread
Sysix marked this conversation as resolved.
Outdated
if server_package_exists && !cfg!(windows) {
let worktree_root_path = worktree.root_path();
let path = Path::new(worktree_root_path.as_str())
.join(SERVER_PATH)
Expand Down Expand Up @@ -67,8 +73,8 @@ impl OxcExtension {
Ok(()) => {
if !self.server_exists(fallback_server_path) {
Err(format!(
"installed package '{PACKAGE_NAME}' did not contain expected path '{fallback_server_path:?}'",
))?;
"installed package '{PACKAGE_NAME}' did not contain expected path '{fallback_server_path:?}'",
))?;
}
}
Err(error) => {
Expand Down