From 5858e613278dd1890d5ca57d5e9da239d0495e40 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 12 Mar 2025 14:42:12 -0400 Subject: [PATCH] purescript: Extract to zed-extensions/purescript repository (#26571) This PR extracts the PureScript extension to the [zed-extensions/purescript](https://github.com/zed-extensions/purescript) repository. Release Notes: - N/A --- Cargo.lock | 7 - Cargo.toml | 1 - docs/src/languages/purescript.md | 2 +- extensions/purescript/Cargo.toml | 16 -- extensions/purescript/LICENSE-APACHE | 1 - extensions/purescript/extension.toml | 15 -- .../languages/purescript/brackets.scm | 3 - .../languages/purescript/config.toml | 14 -- .../languages/purescript/highlights.scm | 144 ------------------ .../languages/purescript/indents.scm | 3 - extensions/purescript/src/purescript.rs | 97 ------------ 11 files changed, 1 insertion(+), 302 deletions(-) delete mode 100644 extensions/purescript/Cargo.toml delete mode 120000 extensions/purescript/LICENSE-APACHE delete mode 100644 extensions/purescript/extension.toml delete mode 100644 extensions/purescript/languages/purescript/brackets.scm delete mode 100644 extensions/purescript/languages/purescript/config.toml delete mode 100644 extensions/purescript/languages/purescript/highlights.scm delete mode 100644 extensions/purescript/languages/purescript/indents.scm delete mode 100644 extensions/purescript/src/purescript.rs diff --git a/Cargo.lock b/Cargo.lock index 426e708113..af93eab2fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17204,13 +17204,6 @@ dependencies = [ "zed_extension_api 0.1.0", ] -[[package]] -name = "zed_purescript" -version = "0.1.0" -dependencies = [ - "zed_extension_api 0.1.0", -] - [[package]] name = "zed_ruff" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d9a0ec9cba..f283f665a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -174,7 +174,6 @@ members = [ "extensions/html", "extensions/perplexity", "extensions/proto", - "extensions/purescript", "extensions/ruff", "extensions/slash-commands-example", "extensions/snippets", diff --git a/docs/src/languages/purescript.md b/docs/src/languages/purescript.md index 007a83dd50..a3e3de3cd3 100644 --- a/docs/src/languages/purescript.md +++ b/docs/src/languages/purescript.md @@ -1,6 +1,6 @@ # PureScript -PureScript support is available through the [PureScript extension](https://github.com/zed-industries/zed/tree/main/extensions/purescript). +PureScript support is available through the [PureScript extension](https://github.com/zed-extensions/purescript). - Tree-sitter: [postsolar/tree-sitter-purescript](https://github.com/postsolar/tree-sitter-purescript) - Language-Server: [nwolverson/purescript-language-server](https://github.com/nwolverson/purescript-language-server) diff --git a/extensions/purescript/Cargo.toml b/extensions/purescript/Cargo.toml deleted file mode 100644 index 8dab673174..0000000000 --- a/extensions/purescript/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "zed_purescript" -version = "0.1.0" -edition.workspace = true -publish.workspace = true -license = "Apache-2.0" - -[lints] -workspace = true - -[lib] -path = "src/purescript.rs" -crate-type = ["cdylib"] - -[dependencies] -zed_extension_api = "0.1.0" diff --git a/extensions/purescript/LICENSE-APACHE b/extensions/purescript/LICENSE-APACHE deleted file mode 120000 index 1cd601d0a3..0000000000 --- a/extensions/purescript/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/extensions/purescript/extension.toml b/extensions/purescript/extension.toml deleted file mode 100644 index 26ca90fc96..0000000000 --- a/extensions/purescript/extension.toml +++ /dev/null @@ -1,15 +0,0 @@ -id = "purescript" -name = "PureScript" -description = "PureScript support." -version = "0.1.0" -schema_version = 1 -authors = ["Iván Molina Rebolledo "] -repository = "https://github.com/zed-industries/zed" - -[language_servers.purescript-language-server] -name = "PureScript Language Server" -language = "PureScript" - -[grammars.purescript] -repository = "https://github.com/postsolar/tree-sitter-purescript" -commit = "0554811a512b9cec08b5a83ce9096eb22da18213" diff --git a/extensions/purescript/languages/purescript/brackets.scm b/extensions/purescript/languages/purescript/brackets.scm deleted file mode 100644 index 191fd9c084..0000000000 --- a/extensions/purescript/languages/purescript/brackets.scm +++ /dev/null @@ -1,3 +0,0 @@ -("(" @open ")" @close) -("[" @open "]" @close) -("{" @open "}" @close) diff --git a/extensions/purescript/languages/purescript/config.toml b/extensions/purescript/languages/purescript/config.toml deleted file mode 100644 index 350f476978..0000000000 --- a/extensions/purescript/languages/purescript/config.toml +++ /dev/null @@ -1,14 +0,0 @@ -name = "PureScript" -grammar = "purescript" -path_suffixes = ["purs"] -autoclose_before = ",=)}]" -line_comments = ["-- "] -block_comment = ["{- ", " -}"] -brackets = [ - { start = "{", end = "}", close = true, newline = true }, - { start = "[", end = "]", close = true, newline = true }, - { start = "(", end = ")", close = true, newline = true }, - { start = "\"", end = "\"", close = true, newline = false }, - { start = "'", end = "'", close = true, newline = false }, - { start = "`", end = "`", close = true, newline = false }, -] diff --git a/extensions/purescript/languages/purescript/highlights.scm b/extensions/purescript/languages/purescript/highlights.scm deleted file mode 100644 index fe2db3115d..0000000000 --- a/extensions/purescript/languages/purescript/highlights.scm +++ /dev/null @@ -1,144 +0,0 @@ -;; Copyright 2022 nvim-treesitter -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. - -;; ---------------------------------------------------------------------------- -;; Literals and comments - -(integer) @number -(exp_negation) @number -(exp_literal (number)) @float -(char) @string -[ - (string) - (triple_quote_string) -] @string - -(comment) @comment - - -;; ---------------------------------------------------------------------------- -;; Punctuation - -[ - "(" - ")" - "{" - "}" - "[" - "]" -] @punctuation.bracket - -[ - (comma) - ";" -] @punctuation.delimiter - - -;; ---------------------------------------------------------------------------- -;; Keywords, operators, includes - -[ - "forall" - "∀" -] @keyword - -;; (pragma) @constant - -[ - "if" - "then" - "else" - "case" - "of" -] @keyword - -[ - "import" - "module" -] @keyword - -[ - (operator) - (constructor_operator) - (type_operator) - (qualified_module) ; grabs the `.` (dot), ex: import System.IO - (all_names) - (wildcard) - "=" - "|" - "::" - "=>" - "->" - "<-" - "\\" - "`" - "@" - "∷" - "⇒" - "<=" - "⇐" - "→" - "←" -] @operator - -(module) @title - -[ - (where) - "let" - "in" - "class" - "instance" - "derive" - "foreign" - "data" - "newtype" - "type" - "as" - "hiding" - "do" - "ado" - "infix" - "infixl" - "infixr" -] @keyword - - -;; ---------------------------------------------------------------------------- -;; Functions and variables - -(variable) @variable -(pat_wildcard) @variable - -(signature name: (variable) @type) -(function - name: (variable) @function - patterns: (patterns)) - - -(exp_infix (exp_name) @function (#set! "priority" 101)) -(exp_apply . (exp_name (variable) @function)) -(exp_apply . (exp_name (qualified_variable (variable) @function))) - - -;; ---------------------------------------------------------------------------- -;; Types - -(type) @type -(type_variable) @type - -(constructor) @constructor - -; True or False -((constructor) @_bool (#match? @_bool "(True|False)")) @boolean diff --git a/extensions/purescript/languages/purescript/indents.scm b/extensions/purescript/languages/purescript/indents.scm deleted file mode 100644 index 112b414aa4..0000000000 --- a/extensions/purescript/languages/purescript/indents.scm +++ /dev/null @@ -1,3 +0,0 @@ -(_ "[" "]" @end) @indent -(_ "{" "}" @end) @indent -(_ "(" ")" @end) @indent diff --git a/extensions/purescript/src/purescript.rs b/extensions/purescript/src/purescript.rs deleted file mode 100644 index be12592a3b..0000000000 --- a/extensions/purescript/src/purescript.rs +++ /dev/null @@ -1,97 +0,0 @@ -use std::{env, fs}; -use zed_extension_api::{self as zed, serde_json, Result}; - -const SERVER_PATH: &str = "node_modules/.bin/purescript-language-server"; -const PACKAGE_NAME: &str = "purescript-language-server"; - -struct PurescriptExtension { - did_find_server: bool, -} - -impl PurescriptExtension { - fn server_exists(&self) -> bool { - fs::metadata(SERVER_PATH).map_or(false, |stat| stat.is_file()) - } - - fn server_script_path(&mut self, language_server_id: &zed::LanguageServerId) -> Result { - let server_exists = self.server_exists(); - if self.did_find_server && server_exists { - return Ok(SERVER_PATH.to_string()); - } - - zed::set_language_server_installation_status( - language_server_id, - &zed::LanguageServerInstallationStatus::CheckingForUpdate, - ); - let version = zed::npm_package_latest_version(PACKAGE_NAME)?; - - if !server_exists - || zed::npm_package_installed_version(PACKAGE_NAME)?.as_ref() != Some(&version) - { - zed::set_language_server_installation_status( - language_server_id, - &zed::LanguageServerInstallationStatus::Downloading, - ); - let result = zed::npm_install_package(PACKAGE_NAME, &version); - match result { - Ok(()) => { - if !self.server_exists() { - Err(format!( - "installed package '{PACKAGE_NAME}' did not contain expected path '{SERVER_PATH}'", - ))?; - } - } - Err(error) => { - if !self.server_exists() { - Err(error)?; - } - } - } - } - - self.did_find_server = true; - Ok(SERVER_PATH.to_string()) - } -} - -impl zed::Extension for PurescriptExtension { - fn new() -> Self { - Self { - did_find_server: false, - } - } - - fn language_server_command( - &mut self, - language_server_id: &zed::LanguageServerId, - _worktree: &zed::Worktree, - ) -> Result { - let server_path = self.server_script_path(language_server_id)?; - Ok(zed::Command { - command: zed::node_binary_path()?, - args: vec![ - env::current_dir() - .unwrap() - .join(&server_path) - .to_string_lossy() - .to_string(), - "--stdio".to_string(), - ], - env: Default::default(), - }) - } - - fn language_server_initialization_options( - &mut self, - _language_server_id: &zed::LanguageServerId, - _worktree: &zed::Worktree, - ) -> Result> { - Ok(Some(serde_json::json!({ - "purescript": { - "addSpagoSources": true - } - }))) - } -} - -zed::register_extension!(PurescriptExtension);