use std::sync::Arc;
use tokio::io::AsyncRead;
use tokio::io::AsyncWrite;
use tower_lsp::LspService;
use tower_lsp::Server;
mod backend;
mod capabilities;
pub(crate) mod config;
mod diagnostics;
mod document;
mod file_analysis;
mod linter;
mod position;
mod state;
mod workspace;
#[cfg(test)]
mod tests;
pub use backend::Backend;
pub use config::ServerConfig;
pub async fn run(config: ServerConfig) {
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
serve(stdin, stdout, config).await;
}
pub async fn serve<R, W>(reader: R, writer: W, config: ServerConfig)
where
R: AsyncRead + Unpin,
W: AsyncWrite + Unpin,
{
let config = Arc::new(config);
let (service, socket) = LspService::new(move |client| Backend::new(client, Arc::clone(&config)));
Server::new(reader, writer, socket).serve(service).await;
}