Skip to content

Commit 9c26710

Browse files
arielherselflpil
authored andcommitted
feat(lsp): check if stdin is tty before printing the user-friendly message
1 parent b8ad707 commit 9c26710

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler-cli/src/lsp.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use gleam_core::{
1212
pub fn main() -> Result<()> {
1313
tracing::info!("language_server_starting");
1414

15-
eprintln!(
16-
"Hello human!
15+
if std::io::IsTerminal::is_terminal(&std::io::stdin()) {
16+
eprintln!(
17+
"Hello human!
1718
1819
This command is intended to be run by language server clients such
1920
as a text editor rather than being run directly in the console.
@@ -22,13 +23,11 @@ Many editors will automatically start the language server for you
2223
when you open a Gleam project. If yours does not you may need to
2324
look up how to configure your editor to use a language server.
2425
25-
If you are seeing this in the logs of your editor you can safely
26-
ignore this message.
27-
2826
If you have run `gleam lsp` yourself in your terminal then exit
2927
this program by pressing ctrl+c.
3028
"
31-
);
29+
);
30+
}
3231

3332
// Create the transport. Includes the stdio (stdin and stdout) versions but this could
3433
// also be implemented to use sockets or HTTP.

0 commit comments

Comments
 (0)