Skip to content

print warning when trying to run serve command in TTY #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged
Changes from all 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
24 changes: 24 additions & 0 deletions crates/djls-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,37 @@ mod server;
mod session;
mod workspace;

use std::io::IsTerminal;

use anyhow::Result;
use tower_lsp_server::LspService;
use tower_lsp_server::Server;

use crate::server::DjangoLanguageServer;

pub fn run() -> Result<()> {
if std::io::stdin().is_terminal() {
eprintln!(
"---------------------------------------------------------------------------------"
);
eprintln!("Django Language Server is running directly in a terminal.");
eprintln!(
"This server is designed to communicate over stdin/stdout with a language client."
);
eprintln!("It is not intended to be used directly in a terminal.");
eprintln!();
eprintln!(
"Note: The server is now waiting for LSP messages, but since you're in a terminal,"
);
eprintln!("no editor is connected and the server won't do anything.");
eprintln!();
eprintln!("To exit: Press ENTER to send invalid input and trigger an error exit.");
eprintln!("Ctrl+C will not work as expected due to LSP stdio communication.");
eprintln!(
"---------------------------------------------------------------------------------"
);
}

let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
Expand Down