Skip to main content

hjkl_lsp/
lib.rs

1//! LSP client for hjkl. See module docs.
2
3pub mod codec;
4pub mod config;
5pub mod encoding;
6pub mod event;
7mod manager;
8pub mod params;
9mod runtime;
10mod server;
11pub mod uri;
12pub mod workspace;
13
14pub use config::{LspConfig, ServerConfig};
15pub use encoding::PositionEncoding;
16pub use event::{LspCommand, LspEvent, RpcError, ServerKey, TextChange};
17pub use manager::LspManager;
18pub use server::Server;
19
20pub type BufferId = u64;
21
22/// Test helpers exposed for integration tests in `tests/`.
23pub mod testing {
24    use crossbeam_channel::Sender;
25    use tokio::io::{AsyncRead, AsyncWrite};
26
27    use crate::event::{LspEvent, ServerKey};
28    use crate::server;
29
30    /// Spawn a `Server` using arbitrary I/O instead of a real child process.
31    /// Used by integration tests in `tests/mock_server.rs`.
32    pub async fn spawn_server_from_io<R, W>(
33        key: ServerKey,
34        stdin_writer: W,
35        stdout_reader: R,
36        evt_tx: Sender<LspEvent>,
37    ) -> anyhow::Result<server::Server>
38    where
39        R: AsyncRead + Unpin + Send + 'static,
40        W: AsyncWrite + Unpin + Send + 'static,
41    {
42        server::spawn_from_io(key, stdin_writer, stdout_reader, evt_tx).await
43    }
44}