-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add Expert LSP support for Elixir #9398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| use std::path::Path; | ||
| use std::sync::Arc; | ||
|
|
||
| use crate::language_server_candidate::{LanguageServerCandidate, LanguageServerMetadata}; | ||
| use crate::CommandBuilder; | ||
| use async_trait::async_trait; | ||
|
|
||
| #[cfg_attr(not(feature = "local_fs"), allow(dead_code))] | ||
| pub struct ExpertCandidate { | ||
| #[allow(dead_code)] | ||
| client: Arc<http_client::Client>, | ||
| } | ||
|
|
||
| impl ExpertCandidate { | ||
| pub fn new(client: Arc<http_client::Client>) -> Self { | ||
| Self { client } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| #[cfg(feature = "local_fs")] | ||
| impl LanguageServerCandidate for ExpertCandidate { | ||
| async fn should_suggest_for_repo(&self, path: &Path, executor: &CommandBuilder) -> bool { | ||
| (path.join("mix.exs").exists() | ||
| || path.join("mix.lock").exists() | ||
| || path.join(".formatter.exs").exists()) | ||
| && self.is_installed_on_path(executor).await | ||
| } | ||
|
|
||
| async fn is_installed_in_data_dir(&self, _executor: &CommandBuilder) -> bool { | ||
| false | ||
| } | ||
|
|
||
| async fn is_installed_on_path(&self, executor: &CommandBuilder) -> bool { | ||
| executor | ||
| .command("start_expert") | ||
| .arg("--help") | ||
| .output() | ||
| .await | ||
| .map(|o| o.status.success()) | ||
| .unwrap_or(false) | ||
| } | ||
|
|
||
| async fn install( | ||
| &self, | ||
| _metadata: LanguageServerMetadata, | ||
| _executor: &CommandBuilder, | ||
| ) -> anyhow::Result<()> { | ||
| anyhow::bail!( | ||
| "Install Expert manually: download from https://github.com/expert-lsp/expert/releases and place `start_expert` on your PATH" | ||
| ) | ||
| } | ||
|
|
||
| async fn fetch_latest_server_metadata(&self) -> anyhow::Result<LanguageServerMetadata> { | ||
| anyhow::bail!( | ||
| "Auto-install not supported; download from https://github.com/expert-lsp/expert/releases" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| #[cfg(not(feature = "local_fs"))] | ||
| impl LanguageServerCandidate for ExpertCandidate { | ||
| async fn should_suggest_for_repo(&self, _path: &Path, _executor: &CommandBuilder) -> bool { | ||
| false | ||
| } | ||
|
|
||
| async fn is_installed_in_data_dir(&self, _executor: &CommandBuilder) -> bool { | ||
| false | ||
| } | ||
|
|
||
| async fn is_installed_on_path(&self, _executor: &CommandBuilder) -> bool { | ||
| false | ||
| } | ||
|
|
||
| async fn install( | ||
| &self, | ||
| _metadata: LanguageServerMetadata, | ||
| _executor: &CommandBuilder, | ||
| ) -> anyhow::Result<()> { | ||
| todo!() | ||
| } | ||
|
|
||
| async fn fetch_latest_server_metadata(&self) -> anyhow::Result<LanguageServerMetadata> { | ||
| todo!() | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| pub mod clangd; | ||
| pub mod expert; | ||
| pub mod go; | ||
| pub mod pyright; | ||
| pub mod rust; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| use std::sync::Arc; | ||
|
|
||
| use crate::servers::clangd::ClangdCandidate; | ||
| use crate::servers::expert::ExpertCandidate; | ||
| use crate::servers::go::GoPlsCandidate; | ||
| use crate::servers::pyright::PyrightCandidate; | ||
| use crate::servers::rust::RustAnalyzerCandidate; | ||
|
|
@@ -42,6 +43,7 @@ pub enum LSPServerType { | |
| Pyright, | ||
| TypeScriptLanguageServer, | ||
| Clangd, | ||
| Expert, | ||
| } | ||
|
|
||
| /// Provides server-specific configuration for each LSP server type. | ||
|
|
@@ -109,6 +111,7 @@ impl LSPServerType { | |
| binary_path: path, | ||
| prepend_args: vec![], | ||
| }), | ||
| LSPServerType::Expert => None, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -132,6 +135,7 @@ impl LSPServerType { | |
| LSPServerType::Pyright => "pyright-langserver", | ||
| LSPServerType::TypeScriptLanguageServer => "typescript-language-server", | ||
| LSPServerType::Clangd => "clangd", | ||
| LSPServerType::Expert => "start_expert", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -140,7 +144,9 @@ impl LSPServerType { | |
| fn args(&self) -> Vec<&'static str> { | ||
| match self { | ||
| LSPServerType::RustAnalyzer | LSPServerType::GoPls | LSPServerType::Clangd => vec![], | ||
| LSPServerType::Pyright | LSPServerType::TypeScriptLanguageServer => vec!["--stdio"], | ||
| LSPServerType::Pyright | ||
| | LSPServerType::TypeScriptLanguageServer | ||
| | LSPServerType::Expert => vec!["--stdio"], | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -154,6 +160,7 @@ impl LSPServerType { | |
| LSPServerType::Pyright => vec!["--stdio"], | ||
| LSPServerType::TypeScriptLanguageServer => vec!["--stdio"], | ||
| LSPServerType::Clangd => vec![], | ||
| LSPServerType::Expert => vec!["--stdio"], | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -172,6 +179,7 @@ impl LSPServerType { | |
| ] | ||
| } | ||
| LSPServerType::Clangd => vec![LanguageId::C, LanguageId::Cpp], | ||
| LSPServerType::Expert => vec![LanguageId::Elixir], | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -205,6 +213,7 @@ impl LSPServerType { | |
| Box::new(TypeScriptLanguageServerCandidate::new(client)) | ||
| } | ||
| LSPServerType::Clangd => Box::new(ClangdCandidate::new(client)), | ||
| LSPServerType::Expert => Box::new(ExpertCandidate::new(client)), | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.eex/.heex/.leex/.neextoLanguageId::ElixirmakesdidOpensend languageIdelixirfor template files. Expert/editor configs treat EEx/HEEx as distinct filetypes (eelixir/heex), so template buffers can be parsed as plain Elixir; add distinct language IDs or otherwise send the template-specific identifiers.