@@ -5,7 +5,7 @@ use crate::{
6type Result<T> = core::result::Result<T, Error>;
6type Result<T> = core::result::Result<T, Error>;
8−use helix_core::{ChangeSet, Rope, RopeSlice, Transaction};
8+use helix_core::{ChangeSet, Rope};
10// use std::collections::HashMap;
10// use std::collections::HashMap;
11use std::sync::atomic::{AtomicU64, Ordering};
11use std::sync::atomic::{AtomicU64, Ordering};
@@ -18,13 +18,12 @@ use smol::{
18 channel::{Receiver, Sender},
18 channel::{Receiver, Sender},
19 io::{BufReader, BufWriter},
19 io::{BufReader, BufWriter},
20 // prelude::*,
20 // prelude::*,
21− process::{Child, ChildStderr, Command, Stdio},
21+ process::{Child, Command, Stdio},
25pub struct Client {
25pub struct Client {
26 _process: Child,
26 _process: Child,
27− stderr: BufReader<ChildStderr>,
29 outgoing: Sender<Payload>,
28 outgoing: Sender<Payload>,
30 // pub incoming: Receiver<Call>,
29 // pub incoming: Receiver<Call>,
@@ -51,11 +50,10 @@ impl Client {
51 let reader = BufReader::new(process.stdout.take().expect("Failed to open stdout"));
50 let reader = BufReader::new(process.stdout.take().expect("Failed to open stdout"));
52 let stderr = BufReader::new(process.stderr.take().expect("Failed to open stderr"));
51 let stderr = BufReader::new(process.stderr.take().expect("Failed to open stderr"));
54− let (incoming, outgoing) = Transport::start(ex, reader, writer);
53+ let (incoming, outgoing) = Transport::start(ex, reader, writer, stderr);
56 let client = Client {
55 let client = Client {
57 _process: process,
56 _process: process,
61 // incoming,
59 // incoming,
@@ -76,17 +74,15 @@ impl Client {
76 jsonrpc::Id::Num(id)
74 jsonrpc::Id::Num(id)
79− fn to_params(value: Value) -> Result<jsonrpc::Params> {
77+ fn value_into_params(value: Value) -> jsonrpc::Params {
80 use jsonrpc::Params;
78 use jsonrpc::Params;
82− let params = match value {
80+ match value {
83 Value::Null => Params::None,
81 Value::Null => Params::None,
84 Value::Bool(_) | Value::Number(_) | Value::String(_) => Params::Array(vec![value]),
82 Value::Bool(_) | Value::Number(_) | Value::String(_) => Params::Array(vec![value]),
85 Value::Array(vec) => Params::Array(vec),
83 Value::Array(vec) => Params::Array(vec),
86 Value::Object(map) => Params::Map(map),
84 Value::Object(map) => Params::Map(map),
92 /// Execute a RPC request on the language server.
88 /// Execute a RPC request on the language server.
@@ -101,7 +97,7 @@ impl Client {
101 jsonrpc: Some(jsonrpc::Version::V2),
97 jsonrpc: Some(jsonrpc::Version::V2),
102 id: self.next_request_id(),
98 id: self.next_request_id(),
103 method: R::METHOD.to_string(),
99 method: R::METHOD.to_string(),
104− params: Self::to_params(params)?,
100+ params: Self::value_into_params(params),
107 let (tx, rx) = smol::channel::bounded::<Result<Value>>(1);
103 let (tx, rx) = smol::channel::bounded::<Result<Value>>(1);
@@ -143,7 +139,7 @@ impl Client {
143 let notification = jsonrpc::Notification {
139 let notification = jsonrpc::Notification {
144 jsonrpc: Some(jsonrpc::Version::V2),
140 jsonrpc: Some(jsonrpc::Version::V2),
145 method: R::METHOD.to_string(),
141 method: R::METHOD.to_string(),
146− params: Self::to_params(params)?,
142+ params: Self::value_into_params(params),
149 self.outgoing
145 self.outgoing
@@ -251,7 +247,7 @@ impl Client {
254− fn to_changes(
250+ fn changeset_to_changes(
255 old_text: &Rope,
251 old_text: &Rope,
256 changeset: &ChangeSet,
252 changeset: &ChangeSet,
257 ) -> Vec<lsp::TextDocumentContentChangeEvent> {
253 ) -> Vec<lsp::TextDocumentContentChangeEvent> {
@@ -346,7 +342,7 @@ impl Client {
346 text: "".to_string(),
342 text: "".to_string(),
347 }] // TODO: probably need old_state here too?
343 }] // TODO: probably need old_state here too?
349− lsp::TextDocumentSyncKind::Incremental => Self::to_changes(old_text, changes),
345+ lsp::TextDocumentSyncKind::Incremental => Self::changeset_to_changes(old_text, changes),
350 lsp::TextDocumentSyncKind::None => return Ok(()),
346 lsp::TextDocumentSyncKind::None => return Ok(()),