
This fixes #9292 by adding a section to the language server settings that allows users to specify the binary path and arguments with which to start up a language server. Example user settings for `rust-analyzer`: ```json { "lsp": { "rust-analyzer": { "binary": { "path": "/Users/thorstenball/tmp/rust-analyzer-aarch64-apple-darwin", "arguments": ["--no-log-buffering"] } } } } ``` Constraints: * Right now this only allows ABSOLUTE paths. * This is only used by `rust-analyzer` integration right now, but the setting can be used for other language servers. We just need to update the adapters to also respect that setting. Release Notes: - Added ability to specify `rust-analyzer` binary `path` (must be absolute) and `arguments` in user settings. Example: `{"lsp": {"rust-analyzer": {"binary": {"path": "/my/abs/path/rust-analyzer", "arguments": ["--no-log-buffering"] }}}}` ([#9292](https://github.com/zed-industries/zed/issues/9292)). Co-authored-by: Ricard Mallafre <rikitzzz@gmail.com>
52 lines
1.3 KiB
Rust
52 lines
1.3 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 HaskellLanguageServer;
|
|
|
|
#[async_trait(?Send)]
|
|
impl LspAdapter for HaskellLanguageServer {
|
|
fn name(&self) -> LanguageServerName {
|
|
LanguageServerName("hls".into())
|
|
}
|
|
|
|
async fn fetch_latest_server_version(
|
|
&self,
|
|
_: &dyn LspAdapterDelegate,
|
|
) -> Result<Box<dyn 'static + Any + Send>> {
|
|
Ok(Box::new(()))
|
|
}
|
|
|
|
async fn fetch_server_binary(
|
|
&self,
|
|
_version: Box<dyn 'static + Send + Any>,
|
|
_container_dir: PathBuf,
|
|
_: &dyn LspAdapterDelegate,
|
|
) -> Result<LanguageServerBinary> {
|
|
Err(anyhow!(
|
|
"hls (haskell language server) must be installed via ghcup"
|
|
))
|
|
}
|
|
|
|
async fn cached_server_binary(
|
|
&self,
|
|
_: PathBuf,
|
|
_: &dyn LspAdapterDelegate,
|
|
) -> Option<LanguageServerBinary> {
|
|
Some(LanguageServerBinary {
|
|
path: "haskell-language-server-wrapper".into(),
|
|
env: None,
|
|
arguments: vec!["lsp".into()],
|
|
})
|
|
}
|
|
|
|
fn can_be_reinstalled(&self) -> bool {
|
|
false
|
|
}
|
|
|
|
async fn installation_test_binary(&self, _: PathBuf) -> Option<LanguageServerBinary> {
|
|
None
|
|
}
|
|
}
|