1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Language Server Protocol (LSP) server abstraction for [Tower].
//!
//! [Tower]: https://github.com/tower-rs/tower
//!
//! # Example
//!
//! ```rust
//! use tower_lsp_server::jsonrpc::Result;
//! use tower_lsp_server::ls_types::*;
//! use tower_lsp_server::{Client, LanguageServer, LspService, Server};
//!
//! #[derive(Debug)]
//! struct Backend {
//! client: Client,
//! }
//!
//! impl LanguageServer for Backend {
//! async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> {
//! Ok(InitializeResult {
//! capabilities: ServerCapabilities {
//! hover_provider: Some(HoverProviderCapability::Simple(true)),
//! completion_provider: Some(CompletionOptions::default()),
//! ..Default::default()
//! },
//! ..Default::default()
//! })
//! }
//!
//! async fn initialized(&self, _: InitializedParams) {
//! self.client
//! .log_message(MessageType::INFO, "server initialized!")
//! .await;
//! }
//!
//! async fn shutdown(&self) -> Result<()> {
//! Ok(())
//! }
//!
//! async fn completion(&self, _: CompletionParams) -> Result<Option<CompletionResponse>> {
//! Ok(Some(CompletionResponse::Array(vec![
//! CompletionItem::new_simple("Hello".to_string(), "Some detail".to_string()),
//! CompletionItem::new_simple("Bye".to_string(), "More detail".to_string())
//! ])))
//! }
//!
//! async fn hover(&self, _: HoverParams) -> Result<Option<Hover>> {
//! Ok(Some(Hover {
//! contents: HoverContents::Scalar(
//! MarkedString::String("You're hovering!".to_string())
//! ),
//! range: None
//! }))
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() {
//! # tracing_subscriber::fmt().init();
//! #
//! # #[cfg(feature = "runtime-agnostic")]
//! # use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};
//! # use std::io::Cursor;
//! let stdin = tokio::io::stdin();
//! let stdout = tokio::io::stdout();
//! # let message = r#"{"jsonrpc":"2.0","method":"exit"}"#;
//! # let (stdin, stdout) = (Cursor::new(format!("Content-Length: {}\r\n\r\n{}", message.len(), message).into_bytes()), Cursor::new(Vec::new()));
//! # #[cfg(feature = "runtime-agnostic")]
//! # let (stdin, stdout) = (stdin.compat(), stdout.compat_write());
//!
//! let (service, socket) = LspService::new(|client| Backend { client });
//! Server::new(stdin, stdout, socket).serve(service).await;
//! }
//! ```
/// A re-export of [`lsp-types`](https://docs.rs/lsp-types) for convenience.
pub use ls_types;
pub use LanguageServer;
pub use ;
pub use ;
pub use ;