@@ -35,6 +35,7 @@ pub struct Client {
35 root_path: Option<std::path::PathBuf>,
35 root_path: Option<std::path::PathBuf>,
36 root_uri: Option<lsp::Url>,
36 root_uri: Option<lsp::Url>,
37 workspace_folders: Vec<lsp::WorkspaceFolder>,
37 workspace_folders: Vec<lsp::WorkspaceFolder>,
40impl Client {
41impl Client {
@@ -45,6 +46,7 @@ impl Client {
45 config: Option<Value>,
46 config: Option<Value>,
46 root_markers: &[String],
47 root_markers: &[String],
47 id: usize,
48 id: usize,
48 ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
50 ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
49 // Resolve path to the binary
51 // Resolve path to the binary
50 let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
52 let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
@@ -97,6 +99,7 @@ impl Client {
97 capabilities: OnceCell::new(),
99 capabilities: OnceCell::new(),
98 offset_encoding: OffsetEncoding::Utf8,
100 offset_encoding: OffsetEncoding::Utf8,
101 root_path,
104 root_path,
102 root_uri,
105 root_uri,
@@ -170,6 +173,7 @@ impl Client {
171 let server_tx = self.server_tx.clone();
174 let server_tx = self.server_tx.clone();
172 let id = self.next_request_id();
175 let id = self.next_request_id();
176+ let timeout_secs = self.req_timeout;
174 async move {
178 async move {
175 use std::time::Duration;
179 use std::time::Duration;
@@ -193,8 +197,8 @@ impl Client {
194 .map_err(|e| Error::Other(e.into()))?;
198 .map_err(|e| Error::Other(e.into()))?;
196− // TODO: specifiable timeout, delay other calls until initialize success
200+ // TODO: delay other calls until initialize success
197− timeout(Duration::from_secs(20), rx.recv())
201+ timeout(Duration::from_secs(timeout_secs), rx.recv())
199 .map_err(|_| Error::Timeout)? // return Timeout
203 .map_err(|_| Error::Timeout)? // return Timeout
200 .ok_or(Error::StreamClosed)?
204 .ok_or(Error::StreamClosed)?