ci: add GitHub Actions workflows with semantic-release auto-versioning
chore: fix all 702 clippy warnings across codebase - auto-fix 475 via cargo clippy --fix - fix remaining 227 manually: uninlined_format_args, redundant_closure, match_same_arms, underscore_binding, format_push_string, items_after_statements, needless_pass_by_value, clone_on_copy, case_sensitive_extension, single_match/let-else, write_with_newline, and other clippy lints
This commit is contained in:
+18
-28
@@ -70,7 +70,7 @@ impl LspManager {
|
||||
language_id: &str,
|
||||
) -> anyhow::Result<()> {
|
||||
if self.servers.iter().any(|s| s.name == name) {
|
||||
anyhow::bail!("LSP server '{}' is already connected", name);
|
||||
anyhow::bail!("LSP server '{name}' is already connected");
|
||||
}
|
||||
let client = LspClient::spawn(command, args)?;
|
||||
self.servers.push(LspServer {
|
||||
@@ -101,7 +101,7 @@ impl LspManager {
|
||||
pub fn disconnect(&mut self, name: &str) -> bool {
|
||||
if let Some(server) = self.servers.iter().find(|s| s.name == name) {
|
||||
if let Ok(mut client) = server.client.lock() {
|
||||
let _ = client.shutdown();
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
let len = self.servers.len();
|
||||
@@ -134,7 +134,7 @@ impl LspManager {
|
||||
pub fn find_server_for_path(&self, path: &Path) -> Option<Arc<Mutex<LspClient>>> {
|
||||
path.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.map(|s| format!(".{}", s))
|
||||
.map(|s| format!(".{s}"))
|
||||
.and_then(|ext| self.find_server_for_extension(&ext))
|
||||
}
|
||||
|
||||
@@ -171,21 +171,15 @@ impl LspManager {
|
||||
/// Non-critical failures (file missing, server unreachable, send
|
||||
/// error) are logged with `tracing::warn!` rather than propagated,
|
||||
/// so a stale notification cannot abort the calling flow.
|
||||
pub fn did_change_file(&mut self, path: &Path) -> anyhow::Result<()> {
|
||||
let ext = match path.extension().and_then(|e| e.to_str()).map(|s| format!(".{}", s)) {
|
||||
Some(ext) => ext,
|
||||
None => {
|
||||
tracing::warn!("did_change_file: path has no extension: {:?}", path);
|
||||
return Ok(());
|
||||
}
|
||||
pub fn did_change_file(&mut self, path: &Path) {
|
||||
let Some(ext) = path.extension().and_then(|e| e.to_str()).map(|s| format!(".{s}")) else {
|
||||
tracing::warn!("did_change_file: path has no extension: {:?}", path);
|
||||
return;
|
||||
};
|
||||
|
||||
let server_name = match self.extension_registry.get(&ext) {
|
||||
Some(name) => name.clone(),
|
||||
None => {
|
||||
tracing::warn!("did_change_file: no LSP server registered for extension '{}'", ext);
|
||||
return Ok(());
|
||||
}
|
||||
let server_name = if let Some(name) = self.extension_registry.get(&ext) { name.clone() } else {
|
||||
tracing::warn!("did_change_file: no LSP server registered for extension '{}'", ext);
|
||||
return;
|
||||
};
|
||||
|
||||
let uri = path_to_lsp_uri(&path.to_string_lossy());
|
||||
@@ -194,7 +188,7 @@ impl LspManager {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
tracing::warn!("did_change_file: failed to read {:?}: {}", path, e);
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -202,12 +196,9 @@ impl LspManager {
|
||||
.get_language_id(&server_name)
|
||||
.unwrap_or_else(|| "plaintext".to_string());
|
||||
|
||||
let client = match self.get_client(&server_name) {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
tracing::warn!("did_change_file: server '{}' has no client", server_name);
|
||||
return Ok(());
|
||||
}
|
||||
let Some(client) = self.get_client(&server_name) else {
|
||||
tracing::warn!("did_change_file: server '{}' has no client", server_name);
|
||||
return;
|
||||
};
|
||||
|
||||
let next_version = match self.open_files.get(&uri) {
|
||||
@@ -220,7 +211,7 @@ impl LspManager {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
tracing::warn!("did_change_file: client mutex poisoned for '{}': {}", server_name, e);
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
};
|
||||
if self.open_files.contains_key(&uri) {
|
||||
@@ -237,7 +228,7 @@ impl LspManager {
|
||||
uri,
|
||||
e
|
||||
);
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
|
||||
self.open_files.insert(
|
||||
@@ -248,7 +239,6 @@ impl LspManager {
|
||||
},
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Record that `server_name` has an open document at `uri`.
|
||||
@@ -274,9 +264,9 @@ impl LspManager {
|
||||
/// drop the vec. Failures from individual shutdowns are swallowed
|
||||
/// because the goal is best-effort termination during teardown.
|
||||
pub fn shutdown_all(&mut self) {
|
||||
for server in self.servers.iter() {
|
||||
for server in &self.servers {
|
||||
if let Ok(mut client) = server.client.lock() {
|
||||
let _ = client.shutdown();
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
self.servers.clear();
|
||||
|
||||
Reference in New Issue
Block a user