[ty] Add warning message when running ty server interactively#23416
[ty] Add warning message when running ty server interactively#23416BurntSushi merged 1 commit intomainfrom
ty server interactively#23416Conversation
crates/ty_server/src/lib.rs
Outdated
| let mut stderr = std::io::stderr(); | ||
| if stderr.is_terminal() { |
There was a problem hiding this comment.
Wait, why are we checking if stderr is a TTY, instead of stdin?
There was a problem hiding this comment.
Hah, oh man. Because I apparently haven't fully woken up yet. Fixed.
There was a problem hiding this comment.
In a real LSP scenario, both stdin and stdout are probably connected to the LSP client. Not sure if it's guaranteed that stderr captured/piped as well? Like, I could imagine a scenario where you want to query information from an LSP server from a CLI application. In this case, you might just want to inherit stderr from the parent process to surface any errors from the LSP directly to the terminal?
There was a problem hiding this comment.
That should work since stdin won't be considered a tty. If the initialization options you send to the LSP server after starting it doesn't have a log file, then tracing is configured to write to stderr.
| writeln!( | ||
| stderr, |
There was a problem hiding this comment.
Did you consider using tracing::warn! here? (do we show these by default?)
There was a problem hiding this comment.
Yes. It was the first thing I tried, but it's not shown by default.
There was a problem hiding this comment.
The issue is that our tracing stuff isn't configured until the server receives its initialization options. But that's well after the point that an end user trying to run ty server directly will be confused.
f98b286 to
5e81b5a
Compare
Closes astral-sh/ty#2851