
This PR adds **internal** ability to run arbitrary language servers via WebAssembly extensions. The functionality isn't exposed yet - we're just landing this in this early state because there have been a lot of changes to the `LspAdapter` trait, and other language server logic. ## Next steps * Currently, wasm extensions can only define how to *install* and run a language server, they can't yet implement the other LSP adapter methods, such as formatting completion labels and workspace symbols. * We don't have an automatic way to install or develop these types of extensions * We don't have a way to package these types of extensions in our extensions repo, to make them available via our extensions API. * The Rust extension API crate, `zed-extension-api` has not yet been published to crates.io, because we still consider the API a work in progress. Release Notes: - N/A --------- Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Nathan <nathan@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
use anyhow::{anyhow, Result};
|
|
use async_trait::async_trait;
|
|
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
|
use lsp::LanguageServerBinary;
|
|
use std::{any::Any, path::PathBuf};
|
|
|
|
pub struct ErlangLspAdapter;
|
|
|
|
#[async_trait]
|
|
impl LspAdapter for ErlangLspAdapter {
|
|
fn name(&self) -> LanguageServerName {
|
|
LanguageServerName("erlang_ls".into())
|
|
}
|
|
|
|
async fn fetch_latest_server_version(
|
|
&self,
|
|
_: &dyn LspAdapterDelegate,
|
|
) -> Result<Box<dyn 'static + Send + Any>> {
|
|
Ok(Box::new(()) as Box<_>)
|
|
}
|
|
|
|
async fn fetch_server_binary(
|
|
&self,
|
|
_version: Box<dyn 'static + Send + Any>,
|
|
_container_dir: PathBuf,
|
|
_: &dyn LspAdapterDelegate,
|
|
) -> Result<LanguageServerBinary> {
|
|
Err(anyhow!(
|
|
"erlang_ls must be installed and available in your $PATH"
|
|
))
|
|
}
|
|
|
|
async fn cached_server_binary(
|
|
&self,
|
|
_: PathBuf,
|
|
_: &dyn LspAdapterDelegate,
|
|
) -> Option<LanguageServerBinary> {
|
|
Some(LanguageServerBinary {
|
|
path: "erlang_ls".into(),
|
|
env: None,
|
|
arguments: vec![],
|
|
})
|
|
}
|
|
|
|
fn can_be_reinstalled(&self) -> bool {
|
|
false
|
|
}
|
|
|
|
async fn installation_test_binary(&self, _: PathBuf) -> Option<LanguageServerBinary> {
|
|
Some(LanguageServerBinary {
|
|
path: "erlang_ls".into(),
|
|
env: None,
|
|
arguments: vec!["--version".into()],
|
|
})
|
|
}
|
|
}
|