Skip to main content

LanguagePlugin

Trait LanguagePlugin 

Source
pub trait LanguagePlugin: Send + Sync {
    // Required methods
    fn language_id(&self) -> &'static str;
    fn file_extensions(&self) -> &'static [&'static str];
    fn marker_files(&self) -> &'static [&'static str];
    fn marker_search_depth(&self) -> u32;
    fn lsp_candidates(&self) -> &[LspCandidate];
    fn install_hint(&self) -> &'static str;
}
Expand description

Per-language LSP behaviour abstraction.

Implementations are pure data providers — no I/O, no async. This makes them trivially testable and composable.

Required Methods§

Source

fn language_id(&self) -> &'static str

Short identifier used as a map key (e.g., "rust", "go", "typescript", "python").

Source

fn file_extensions(&self) -> &'static [&'static str]

File extensions that this language handles.

Used by [language_id_for_extension] and [touch_language] in LT-4. Example: &["rs"] for Rust, &["ts", "tsx", "js", "jsx", "mjs", "cjs", "vue"] for TypeScript.

Source

fn marker_files(&self) -> &'static [&'static str]

Marker files that indicate this language is used in the workspace.

Returned in priority order — detection stops at the first match. Example: &["Cargo.toml"] for Rust, &["tsconfig.json", "package.json"] for TypeScript.

Source

fn marker_search_depth(&self) -> u32

Maximum directory depth to search for marker files.

0 = root only, 2 = root + up to 2 levels deep (for monorepos).

Source

fn lsp_candidates(&self) -> &[LspCandidate]

LSP binary candidates in preference order.

Detection tries each candidate via which and uses the first found. Example: Rust has one (rust-analyzer), Python has four (pyright-langserver, pylsp, ruff-lsp, jedi-language-server).

Source

fn install_hint(&self) -> &'static str

Human-readable install guidance when no LSP binary is found.

Implementors§