Skip to main content

resolve_lsp_command

Function resolve_lsp_command 

Source
pub fn resolve_lsp_command(
    config: &LspServerConfig,
) -> Result<LspCommand, String>
Expand description

Resolves the command to execute an LSP server.

Checks environment variables first, then falls back to the default command. Special handling for rust-analyzer to support rustup-installed versions.

§Errors

Returns an error string if the program cannot be located (e.g. rust-analyzer or gopls are not installed and not found via their fallback discovery logic).

§Examples

use iced_code_editor::{lsp_server_config, resolve_lsp_command};

if let Some(config) = lsp_server_config("lua-language-server") {
    match resolve_lsp_command(config) {
        Ok(cmd) => println!("Run: {}", cmd.program),
        Err(e) => eprintln!("Not found: {e}"),
    }
}