Skip to content

Commit 68ea842

Browse files
print warning when trying to run serve command in TTY (#155)
1 parent b71dfe5 commit 68ea842

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

crates/djls-server/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,37 @@ mod server;
66
mod session;
77
mod workspace;
88

9+
use std::io::IsTerminal;
10+
911
use anyhow::Result;
1012
use tower_lsp_server::LspService;
1113
use tower_lsp_server::Server;
1214

1315
use crate::server::DjangoLanguageServer;
1416

1517
pub fn run() -> Result<()> {
18+
if std::io::stdin().is_terminal() {
19+
eprintln!(
20+
"---------------------------------------------------------------------------------"
21+
);
22+
eprintln!("Django Language Server is running directly in a terminal.");
23+
eprintln!(
24+
"This server is designed to communicate over stdin/stdout with a language client."
25+
);
26+
eprintln!("It is not intended to be used directly in a terminal.");
27+
eprintln!();
28+
eprintln!(
29+
"Note: The server is now waiting for LSP messages, but since you're in a terminal,"
30+
);
31+
eprintln!("no editor is connected and the server won't do anything.");
32+
eprintln!();
33+
eprintln!("To exit: Press ENTER to send invalid input and trigger an error exit.");
34+
eprintln!("Ctrl+C will not work as expected due to LSP stdio communication.");
35+
eprintln!(
36+
"---------------------------------------------------------------------------------"
37+
);
38+
}
39+
1640
let runtime = tokio::runtime::Builder::new_current_thread()
1741
.enable_all()
1842
.build()?;

0 commit comments

Comments
 (0)