Skip to content

Commit bfef743

Browse files
committed
refactor: redirect all output to stderr for LSP compatibility
Move progress/status messages to stderr to keep stdout clean for LSP protocol communication. This eliminates the need to set quiet mode in the LSP server startup.
1 parent 1bf4816 commit bfef743

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

codeinput/src/lsp/server.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ use url::Url;
1717

1818
use crate::core::cache::sync_cache;
1919
use crate::core::types::{CodeownersCache, Owner, OwnerType, Tag};
20-
use crate::utils::{
21-
app_config::AppConfig,
22-
error::{Error, Result},
23-
};
20+
use crate::utils::error::{Error, Result};
2421

2522
/// LSP Server state
2623
pub struct LspServer {
@@ -468,9 +465,6 @@ fn is_codeowners_file(uri: &Url) -> bool {
468465

469466
/// Run the LSP server
470467
pub async fn run_lsp_server() -> Result<()> {
471-
// Set quiet mode for LSP (suppresses progress output)
472-
AppConfig::set("quiet", "true")?;
473-
474468
let stdin = tokio::io::stdin();
475469
let stdout = tokio::io::stdout();
476470

codeinput/src/utils/output.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Output utilities for CLI progress and status messages
2+
//!
3+
//! All output goes to stderr to keep stdout clean for data/LSP protocol.
24
3-
use std::io::Write;
5+
use std::io::{stderr, Write};
46

57
use super::app_config::AppConfig;
68

@@ -9,17 +11,18 @@ fn is_quiet() -> bool {
911
AppConfig::fetch().map(|c| c.quiet).unwrap_or(false)
1012
}
1113

12-
/// Print a message if not in quiet mode
14+
/// Print a message to stderr if not in quiet mode
1315
pub fn print(msg: &str) {
1416
if !is_quiet() {
15-
print!("{}", msg);
16-
std::io::stdout().flush().ok();
17+
let mut stderr = stderr();
18+
write!(stderr, "{}", msg).ok();
19+
stderr.flush().ok();
1720
}
1821
}
1922

20-
/// Print a line if not in quiet mode
23+
/// Print a line to stderr if not in quiet mode
2124
pub fn println(msg: &str) {
2225
if !is_quiet() {
23-
println!("{}", msg);
26+
writeln!(stderr(), "{}", msg).ok();
2427
}
2528
}

0 commit comments

Comments
 (0)