Skip to main content

matrixcode_core/lsp/
constants.rs

1//! LSP timeout configuration constants
2//!
3//! Separated timeout values for different LSP lifecycle phases:
4//! - Process startup (fast, system-level operation)
5//! - Server initialization (slow, needs to build indexes)
6//! - Individual requests (medium, per-call timeout)
7
8use std::time::Duration;
9
10/// Timeout for starting the LSP server process
11///
12/// This is a system-level operation that should complete quickly.
13/// If the process fails to start within this time, it indicates
14/// a fundamental problem (missing binary, permission denied, etc.)
15pub const PROCESS_STARTUP_TIMEOUT: Duration = Duration::from_secs(5);
16
17/// Timeout for initializing the LSP server
18///
19/// This includes building workspace indexes, loading dependencies,
20/// and preparing the server for use. Large projects (especially Rust)
21/// may need 60-120 seconds to fully initialize.
22///
23/// We set this to 120s to accommodate very large Rust projects.
24/// If timeout occurs, the process continues running in background
25/// and status will be updated when ready.
26pub const SERVER_INIT_TIMEOUT: Duration = Duration::from_secs(120);
27
28/// Timeout for individual LSP requests
29///
30/// Each request (hover, definition, references, etc.) has its own
31/// timeout. This prevents slow requests from blocking the entire system.
32pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(30);
33
34/// Legacy timeout constant (deprecated)
35///
36/// This was the original single timeout for entire LSP startup.
37/// Now replaced by PROCESS_STARTUP_TIMEOUT + SERVER_INIT_TIMEOUT.
38/// Kept for backward compatibility during migration.
39#[deprecated(since = "0.1.0", note = "Use PROCESS_STARTUP_TIMEOUT and SERVER_INIT_TIMEOUT instead")]
40pub const LSP_STARTUP_TIMEOUT_SECS: u64 = 5;
41
42/// Legacy wait timeout (backward compatibility)
43///
44/// Maps to SERVER_INIT_TIMEOUT for backward compatibility.
45/// Use SERVER_INIT_TIMEOUT directly in new code.
46pub const LSP_WAIT_TIMEOUT_SECS: u64 = 120;