sync_ls::transport

Function io_transport

Source
pub fn io_transport<I: BufRead, O: Write>(
    kind: MessageKind,
    inp: impl FnOnce() -> I + Send + Sync + 'static,
    out: impl FnOnce() -> O + Send + Sync + 'static,
) -> (Sender<Message>, Receiver<Message>, IoThreads)
Expand description

Creates an LSP connection via io.

§Example

use std::io::{stdin, stdout};
use sync_ls::{Message, MessageKind, transport::{io_transport, IoThreads}};
use crossbeam_channel::{bounded, Receiver, Sender};
pub fn stdio_transport() -> (Sender<Message>, Receiver<Message>, IoThreads) {
  io_transport(MessageKind::Lsp, || stdin().lock(), || stdout().lock())
}