Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Language Server Protocol implementation written in Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

ebkalderon/tower-lsp

Build StatusCrates.ioDocumentation

Language Server Protocol implementation for Rust based onTower.

Tower is a simple and composable framework for implementing asynchronousservices in Rust. Central to Tower is theService trait, which provides thenecessary abstractions for defining request/response clients and servers.Examples of protocols implemented using theService trait includehyper for HTTP andtonic for gRPC.

This library (tower-lsp) provides a simple implementation of the LanguageServer Protocol (LSP) that makes it easy to write your own language server. Itconsists of three parts:

  • TheLanguageServer trait which defines the behavior of your language server.
  • The asynchronousLspService delegate which wraps your language serverimplementation and defines the behavior of the protocol.
  • AServer which spawns theLspService and processes requests and responsesoverstdio or TCP.

Example

use tower_lsp::jsonrpc::Result;use tower_lsp::lsp_types::*;use tower_lsp::{Client,LanguageServer,LspService,Server};#[derive(Debug)]structBackend{client:Client,}#[tower_lsp::async_trait]implLanguageServerforBackend{asyncfninitialize(&self, _:InitializeParams) ->Result<InitializeResult>{Ok(InitializeResult::default())}asyncfninitialized(&self, _:InitializedParams){self.client.log_message(MessageType::INFO,"server initialized!").await;}asyncfnshutdown(&self) ->Result<()>{Ok(())}}#[tokio::main]asyncfnmain(){let stdin = tokio::io::stdin();let stdout = tokio::io::stdout();let(service, socket) =LspService::new(|client|Backend{ client});Server::new(stdin, stdout, socket).serve(service).await;}

Using runtimes other than tokio

By default,tower-lsp is configured for use withtokio.

Usingtower-lsp with other runtimes requires disablingdefault-features andenabling theruntime-agnostic feature:

[dependencies.tower-lsp]version ="*"default-features =falsefeatures = ["runtime-agnostic"]

Using proposed features

You can use enable proposed features in theLSP Specification version 3.18by enabling theproposed Cargo crate feature. Note that there are no semverguarantees to theproposed features so there may be breaking changes betweenany type of version in theproposed features.

Ecosystem

License

tower-lsp is free and open source software distributed under the terms ofeither theMIT or theApache 2.0 license, atyour option.

Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall bedual licensed as above, without any additional terms or conditions.

About

Language Server Protocol implementation written in Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp