-
Notifications
You must be signed in to change notification settings - Fork 61
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
Serve on TCP over stdin #196
Comments
Hey there, @saskenuba! Glad you're experimenting and learning with Rust. I should first point out that With that said, I can see that your code is receiving requests from a #[tokio::main]
async fn main() -> Result<()> {
env_logger::init();
let mut listener = tokio::net::TcpListener::bind("127.0.0.1:9001").await?;
let (stream, _) = listener.accept().await?;
let (read, write) = tokio::io::split(stream);
info!("Starting generic LSP Server..");
let (service, messages) = LspService::new(Backend::default());
Server::new(read, write)
.interleave(messages)
.serve(service)
.await;
Ok(())
} This should allow requests and responses to actually be routed properly over TCP. But as stated previously, the existing message flushing code was not built with TCP in mind, so I highly doubt this will work. I imagine a true TCP language server would instead have separate connections for client-to-server and server-to-client, rather than multiplexing messages over a single stream, like You're more than welcome to submit pull requests, of course! |
Hey, I can't believe I was passing stdout, no wonder the client couldn't read those messages, feeling stupid right now, haha. After adjusting my code, even if not intended, it worked flawlessly over TCP! Thanks! |
That's fantastic news, @saskenuba! I'm glad to hear that Maybe we should update the included example projects to document that this works? We could rename |
Yes! I've used emacs with the eglot package. It offers an ad-hoc way of connecting to LSP servers, that supports both TCP and We really should do it, developing through TCP made it a whole lot easier than snooping file descriptors or logging into separate files. |
Sounds great! I was just able to verify that server-to-client notifications work as expected with coc.nvim and am about to verify server-to-client requests. On the examples side, I think we could rename |
Okay, I've created #198 to update and document how to use |
Is it possible to listen on TCP over stdin? I believe this would make the development a bit easier to follow.
Since Server takes an
AsyncRead + Unpin
I thought it would be simple, but it only answers the first message and the client hangs. I am still noobish with async rust, sorry.Minimal example:
The text was updated successfully, but these errors were encountered: