@@ -35,6 +35,7 @@ pub struct Client {
3535 root_path: Option<std::path::PathBuf>,
3636 root_uri: Option<lsp::Url>,
3737 workspace_folders: Vec<lsp::WorkspaceFolder>,
38+ req_timeout: u64,
3839}
3940
4041impl Client {
@@ -45,6 +46,7 @@ impl Client {
4546 config: Option<Value>,
4647 root_markers: &[String],
4748 id: usize,
49+ req_timeout: u64,
4850 ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
4951 // Resolve path to the binary
5052 let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
@@ -97,6 +99,7 @@ impl Client {
9799 capabilities: OnceCell::new(),
98100 offset_encoding: OffsetEncoding::Utf8,
99101 config,
102+ req_timeout,
100103
101104 root_path,
102105 root_uri,
@@ -170,6 +173,7 @@ impl Client {
170173 {
171174 let server_tx = self.server_tx.clone();
172175 let id = self.next_request_id();
176+ let timeout_secs = self.req_timeout;
173177
174178 async move {
175179 use std::time::Duration;
@@ -193,8 +197,8 @@ impl Client {
193197 })
194198 .map_err(|e| Error::Other(e.into()))?;
195199
196− // TODO: specifiable timeout, delay other calls until initialize success
197− timeout(Duration::from_secs(20), rx.recv())
200+ // TODO: delay other calls until initialize success
201+ timeout(Duration::from_secs(timeout_secs), rx.recv())
198202 .await
199203 .map_err(|_| Error::Timeout)? // return Timeout
200204 .ok_or(Error::StreamClosed)?