diff --git a/Cargo.lock b/Cargo.lock index 25b9edaffe..a19bc0890f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5304,7 +5304,6 @@ dependencies = [ "tree-sitter-go", "tree-sitter-gomod", "tree-sitter-gowork", - "tree-sitter-haskell", "tree-sitter-hcl", "tree-sitter-heex", "tree-sitter-html", @@ -10287,15 +10286,6 @@ dependencies = [ "tree-sitter", ] -[[package]] -name = "tree-sitter-haskell" -version = "0.14.0" -source = "git+https://github.com/tree-sitter/tree-sitter-haskell?rev=8a99848fc734f9c4ea523b3f2a07df133cbbcec2#8a99848fc734f9c4ea523b3f2a07df133cbbcec2" -dependencies = [ - "cc", - "tree-sitter", -] - [[package]] name = "tree-sitter-hcl" version = "0.0.1" @@ -12612,6 +12602,13 @@ dependencies = [ "zed_extension_api 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "zed_haskell" +version = "0.0.1" +dependencies = [ + "zed_extension_api 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "zed_svelte" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index e5d4997cd8..b0599f7ff9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,6 +97,7 @@ members = [ "crates/zed_actions", "extensions/gleam", + "extensions/haskell", "extensions/uiua", "extensions/svelte", @@ -299,7 +300,6 @@ tree-sitter-glsl = { git = "https://github.com/theHamsta/tree-sitter-glsl", rev tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "aeb2f33b366fd78d5789ff104956ce23508b85db" } tree-sitter-gomod = { git = "https://github.com/camdencheek/tree-sitter-go-mod" } tree-sitter-gowork = { git = "https://github.com/d1y/tree-sitter-go-work" } -tree-sitter-haskell = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "8a99848fc734f9c4ea523b3f2a07df133cbbcec2" } tree-sitter-hcl = { git = "https://github.com/MichaHoffmann/tree-sitter-hcl", rev = "v1.1.0" } rustc-demangle = "0.1.23" tree-sitter-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" } diff --git a/crates/extensions_ui/src/extension_suggest.rs b/crates/extensions_ui/src/extension_suggest.rs index b5e7a7ca64..27e48d4902 100644 --- a/crates/extensions_ui/src/extension_suggest.rs +++ b/crates/extensions_ui/src/extension_suggest.rs @@ -32,6 +32,7 @@ pub fn suggested_extension(file_extension_or_name: &str) -> Option> { ("gleam", "gleam"), ("graphql", "gql"), ("graphql", "graphql"), + ("haskell", "haskell"), ("java", "java"), ("kotlin", "kt"), ("latex", "tex"), diff --git a/crates/languages/Cargo.toml b/crates/languages/Cargo.toml index 60f656d7b2..0bb2164902 100644 --- a/crates/languages/Cargo.toml +++ b/crates/languages/Cargo.toml @@ -53,7 +53,6 @@ tree-sitter-glsl.workspace = true tree-sitter-go.workspace = true tree-sitter-gomod.workspace = true tree-sitter-gowork.workspace = true -tree-sitter-haskell.workspace = true tree-sitter-hcl.workspace = true tree-sitter-heex.workspace = true tree-sitter-html.workspace = true diff --git a/crates/languages/src/haskell.rs b/crates/languages/src/haskell.rs deleted file mode 100644 index 224910a04d..0000000000 --- a/crates/languages/src/haskell.rs +++ /dev/null @@ -1,52 +0,0 @@ -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> { - Ok(Box::new(())) - } - - async fn fetch_server_binary( - &self, - _version: Box, - _container_dir: PathBuf, - _: &dyn LspAdapterDelegate, - ) -> Result { - Err(anyhow!( - "hls (haskell language server) must be installed via ghcup" - )) - } - - async fn cached_server_binary( - &self, - _: PathBuf, - _: &dyn LspAdapterDelegate, - ) -> Option { - 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 { - None - } -} diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs index 9c94a107db..71609f89be 100644 --- a/crates/languages/src/lib.rs +++ b/crates/languages/src/lib.rs @@ -23,7 +23,6 @@ mod elixir; mod elm; mod erlang; mod go; -mod haskell; mod html; mod json; mod lua; @@ -85,7 +84,6 @@ pub fn init( ("go", tree_sitter_go::language()), ("gomod", tree_sitter_gomod::language()), ("gowork", tree_sitter_gowork::language()), - ("haskell", tree_sitter_haskell::language()), ("hcl", tree_sitter_hcl::language()), ("heex", tree_sitter_heex::language()), ("html", tree_sitter_html::language()), @@ -316,7 +314,6 @@ pub fn init( } } - language!("haskell", vec![Arc::new(haskell::HaskellLanguageServer {})]); language!( "html", vec![ diff --git a/extensions/haskell/Cargo.toml b/extensions/haskell/Cargo.toml new file mode 100644 index 0000000000..a7a213b2de --- /dev/null +++ b/extensions/haskell/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "zed_haskell" +version = "0.0.1" +edition = "2021" +publish = false +license = "Apache-2.0" + +[lints] +workspace = true + +[lib] +path = "src/haskell.rs" +crate-type = ["cdylib"] + +[dependencies] +zed_extension_api = "0.0.4" diff --git a/extensions/haskell/LICENSE-APACHE b/extensions/haskell/LICENSE-APACHE new file mode 120000 index 0000000000..1cd601d0a3 --- /dev/null +++ b/extensions/haskell/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/extensions/haskell/extension.toml b/extensions/haskell/extension.toml new file mode 100644 index 0000000000..1891a6dcd1 --- /dev/null +++ b/extensions/haskell/extension.toml @@ -0,0 +1,19 @@ +id = "haskell" +name = "Haskell" +description = "Haskell support for Zed" +version = "0.0.1" +schema_version = 1 +authors = [ + "Marshall Bowers ", + "Pseudomata ", + "Lei <45155667+leifu1128@users.noreply.github.com>" +] +repository = "https://github.com/zed-industries/zed" + +[language_servers.hls] +name = "Haskell Language Server" +language = "Haskell" + +[grammars.haskell] +repository = "https://github.com/tree-sitter/tree-sitter-haskell" +commit = "8a99848fc734f9c4ea523b3f2a07df133cbbcec2" diff --git a/crates/languages/src/haskell/brackets.scm b/extensions/haskell/languages/haskell/brackets.scm similarity index 100% rename from crates/languages/src/haskell/brackets.scm rename to extensions/haskell/languages/haskell/brackets.scm diff --git a/crates/languages/src/haskell/config.toml b/extensions/haskell/languages/haskell/config.toml similarity index 100% rename from crates/languages/src/haskell/config.toml rename to extensions/haskell/languages/haskell/config.toml diff --git a/crates/languages/src/haskell/highlights.scm b/extensions/haskell/languages/haskell/highlights.scm similarity index 100% rename from crates/languages/src/haskell/highlights.scm rename to extensions/haskell/languages/haskell/highlights.scm diff --git a/crates/languages/src/haskell/indents.scm b/extensions/haskell/languages/haskell/indents.scm similarity index 100% rename from crates/languages/src/haskell/indents.scm rename to extensions/haskell/languages/haskell/indents.scm diff --git a/crates/languages/src/haskell/outline.scm b/extensions/haskell/languages/haskell/outline.scm similarity index 100% rename from crates/languages/src/haskell/outline.scm rename to extensions/haskell/languages/haskell/outline.scm diff --git a/extensions/haskell/src/haskell.rs b/extensions/haskell/src/haskell.rs new file mode 100644 index 0000000000..c55b76ffbc --- /dev/null +++ b/extensions/haskell/src/haskell.rs @@ -0,0 +1,27 @@ +use zed_extension_api::{self as zed, Result}; + +struct HaskellExtension; + +impl zed::Extension for HaskellExtension { + fn new() -> Self { + Self + } + + fn language_server_command( + &mut self, + _config: zed::LanguageServerConfig, + worktree: &zed::Worktree, + ) -> Result { + let path = worktree + .which("haskell-language-server-wrapper") + .ok_or_else(|| "hls must be installed via ghcup".to_string())?; + + Ok(zed::Command { + command: path, + args: vec!["lsp".to_string()], + env: Default::default(), + }) + } +} + +zed::register_extension!(HaskellExtension);