pub struct ServerHeuristics {
pub project_markers: Vec<String>,
}Expand description
Heuristics for determining if an LSP server should be spawned.
Used to prevent spawning servers in projects where they are not applicable (e.g., rust-analyzer in a Python-only project).
Fields§
§project_markers: Vec<String>Files or directories that indicate this server is applicable.
The server will spawn if ANY of these markers exist anywhere in the workspace tree
(searched recursively up to heuristics_max_depth). Well-known directories like
node_modules, target, .git are excluded from the search.
If empty, the server will always attempt to spawn.
Implementations§
Source§impl ServerHeuristics
impl ServerHeuristics
Sourcepub fn with_markers<I, S>(markers: I) -> Self
pub fn with_markers<I, S>(markers: I) -> Self
Create heuristics with the given project markers.
Sourcepub fn is_applicable(&self, workspace_root: &Path) -> bool
pub fn is_applicable(&self, workspace_root: &Path) -> bool
Check if any marker exists at the given workspace root.
Returns true if:
- No markers are defined (empty = always applicable)
- At least one marker file/directory exists
Sourcepub fn is_applicable_recursive(
&self,
workspace_root: &Path,
max_depth: Option<usize>,
) -> bool
pub fn is_applicable_recursive( &self, workspace_root: &Path, max_depth: Option<usize>, ) -> bool
Check if any marker exists anywhere in the workspace tree.
Recursively searches the workspace for project markers, excluding
well-known directories like node_modules, target, .git, etc.
§Arguments
workspace_root- Root directory to search frommax_depth- Maximum recursion depth (default: 10)
§Returns
true if any marker is found, false otherwise.
Trait Implementations§
Source§impl Clone for ServerHeuristics
impl Clone for ServerHeuristics
Source§fn clone(&self) -> ServerHeuristics
fn clone(&self) -> ServerHeuristics
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more