https://github.com/latex-lsp/language-server
A library to implement language servers in Rust.
https://github.com/latex-lsp/language-server
language-server-protocol rust
Last synced: about 1 year ago
JSON representation
A library to implement language servers in Rust.
- Host: GitHub
- URL: https://github.com/latex-lsp/language-server
- Owner: latex-lsp
- License: mit
- Created: 2020-05-05T12:37:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-23T05:58:16.000Z (almost 5 years ago)
- Last Synced: 2025-03-23T06:11:31.486Z (over 1 year ago)
- Topics: language-server-protocol, rust
- Language: Rust
- Homepage:
- Size: 86.9 KB
- Stars: 32
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/latex-lsp/language-server/actions)
[](https://codecov.io/gh/latex-lsp/language-server)
[](https://blog.rust-lang.org/2019/11/07/Rust-1.39.0.html)
[](https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/)
[](https://dependabot.com)
[](https://crates.io/crates/language-server)
[](https://docs.rs/language-server)
# language-server
A library to implement asynchronous language servers in Rust. It features
- Full server and client support of the
[Language Server Protocol 3.15](https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/).
- Independent of the underlying transport layer and the used async executor.
## Example
A simple language server using the [Tokio](https://tokio.rs/) runtime:
```rust
use async_executors::TokioTp;
use language_server::{async_trait::async_trait, types::*, *};
use std::{convert::TryFrom, sync::Arc};
use tokio_util::compat::*;
struct Server;
#[async_trait]
impl LanguageServer for Server {
async fn initialize(
&self,
_params: InitializeParams,
_client: Arc,
) -> Result {
Ok(InitializeResult::default())
}
async fn initialized(&self, _params: InitializedParams, client: Arc) {
let params = ShowMessageParams {
typ: MessageType::Info,
message: "Hello World!".to_owned(),
};
client.show_message(params).await;
}
}
fn main() {
let executor = TokioTp::try_from(&mut tokio::runtime::Builder::new())
.expect("failed to create thread pool");
executor.block_on(
LanguageService::builder()
.server(Arc::new(Server))
.input(tokio::io::stdin().compat())
.output(tokio::io::stdout().compat_write())
.executor(executor.clone())
.build()
.listen(),
);
}
```
More examples can be found [here](examples).