erlang: Add Erlang Language Platform support (#14879)

Added support for the [Erlang Language
Platform](https://whatsapp.github.io/erlang-language-platform/) language
server to the Erlang extension.

Release Notes:

- N/A

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Fabian Bergström
2024-07-21 11:38:24 -04:00
committed by GitHub
co-authored by Marshall Bowers
parent 2f3df9fd93
commit 7b88fc5cda
4 changed files with 52 additions and 3 deletions
@@ -0,0 +1,33 @@
use zed_extension_api::{self as zed, LanguageServerId, Result};
pub struct ErlangLanguagePlatform;
impl ErlangLanguagePlatform {
pub const LANGUAGE_SERVER_ID: &'static str = "elp";
pub fn new() -> Self {
Self
}
pub fn language_server_command(
&mut self,
language_server_id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
Ok(zed::Command {
command: self.language_server_binary_path(language_server_id, worktree)?,
args: vec!["server".to_string()],
env: Default::default(),
})
}
fn language_server_binary_path(
&mut self,
_language_server_id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<String> {
worktree
.which("elp")
.ok_or_else(|| "elp must be installed and available on your $PATH".to_string())
}
}