clojure: Extract to zed-extensions/clojure repository (#22628)

This PR extracts the Clojure extension to the
[zed-extensions/clojure](https://github.com/zed-extensions/clojure)
repository.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-01-03 16:14:53 -05:00 committed by GitHub
parent a1ef1d3f76
commit fdbf3d0f25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 1 additions and 211 deletions

7
Cargo.lock generated
View file

@ -16324,13 +16324,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "zed_clojure"
version = "0.0.3"
dependencies = [
"zed_extension_api 0.1.0",
]
[[package]] [[package]]
name = "zed_csharp" name = "zed_csharp"
version = "0.1.0" version = "0.1.0"

View file

@ -149,7 +149,6 @@ members = [
# Extensions # Extensions
# #
"extensions/clojure",
"extensions/csharp", "extensions/csharp",
"extensions/deno", "extensions/deno",
"extensions/elixir", "extensions/elixir",

View file

@ -1,6 +1,6 @@
# Clojure # Clojure
Clojure support is available through the [Clojure extension](https://github.com/zed-industries/zed/tree/main/extensions/clojure). Clojure support is available through the [Clojure extension](https://github.com/zed-extensions/clojure).
- Tree Sitter: [prcastro/tree-sitter-clojure](https://github.com/prcastro/tree-sitter-clojure) - Tree Sitter: [prcastro/tree-sitter-clojure](https://github.com/prcastro/tree-sitter-clojure)
- Language Server: [clojure-lsp/clojure-lsp](https://github.com/clojure-lsp/clojure-lsp) - Language Server: [clojure-lsp/clojure-lsp](https://github.com/clojure-lsp/clojure-lsp)

View file

@ -1,16 +0,0 @@
[package]
name = "zed_clojure"
version = "0.0.3"
edition = "2021"
publish = false
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/clojure.rs"
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.1.0"

View file

@ -1 +0,0 @@
../../LICENSE-APACHE

View file

@ -1,15 +0,0 @@
id = "clojure"
name = "Clojure"
description = "Clojure support."
version = "0.0.3"
schema_version = 1
authors = ["Paulo Roberto de Oliveira Castro <p.oliveira.castro@gmail.com>"]
repository = "https://github.com/zed-industries/zed"
[language_servers.clojure-lsp]
name = "clojure-lsp"
language = "Clojure"
[grammars.clojure]
repository = "https://github.com/prcastro/tree-sitter-clojure"
commit = "38b4f8d264248b2fd09575fbce66f7c22e8929d5"

View file

@ -1,3 +0,0 @@
("(" @open ")" @close)
("[" @open "]" @close)
("{" @open "}" @close)

View file

@ -1,12 +0,0 @@
name = "Clojure"
grammar = "clojure"
path_suffixes = ["clj", "cljs", "cljc", "cljd", "edn", "bb"]
line_comments = [";; "]
autoclose_before = "}])"
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, not_in = ["string"] },
]
word_characters = ["-"]

View file

@ -1,41 +0,0 @@
;; Literals
(num_lit) @number
[
(char_lit)
(str_lit)
] @string
[
(bool_lit)
(nil_lit)
] @constant.builtin
(kwd_lit) @constant
;; Comments
(comment) @comment
;; Treat quasiquotation as operators for the purpose of highlighting.
[
"'"
"`"
"~"
"@"
"~@"
] @operator
(list_lit
.
(sym_lit) @function)
(list_lit
.
(sym_lit) @keyword
(#match? @keyword
"^(do|if|let|var|fn|fn*|loop*|recur|throw|try|catch|finally|set!|new|quote|->|->>)$"
))

View file

@ -1,3 +0,0 @@
(_ "[" "]") @indent
(_ "{" "}") @indent
(_ "(" ")") @indent

View file

@ -1,109 +0,0 @@
use std::fs;
use zed_extension_api::{self as zed, LanguageServerId, Result};
struct ClojureExtension {
cached_binary_path: Option<String>,
}
impl ClojureExtension {
fn language_server_binary_path(
&mut self,
language_server_id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<String> {
if let Some(path) = worktree.which("clojure-lsp") {
return Ok(path);
}
if let Some(path) = &self.cached_binary_path {
if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
return Ok(path.clone());
}
}
zed::set_language_server_installation_status(
language_server_id,
&zed::LanguageServerInstallationStatus::CheckingForUpdate,
);
let release = zed::latest_github_release(
"clojure-lsp/clojure-lsp",
zed::GithubReleaseOptions {
require_assets: true,
pre_release: false,
},
)?;
let (platform, arch) = zed::current_platform();
let asset_name = format!(
"clojure-lsp-native-{os}-{arch}.zip",
os = match platform {
zed::Os::Mac => "macos",
zed::Os::Linux => "linux",
zed::Os::Windows => "windows",
},
arch = match arch {
zed::Architecture::Aarch64 => "aarch64",
zed::Architecture::X8664 => "amd64",
zed::Architecture::X86 =>
return Err(format!("unsupported architecture: {arch:?}")),
},
);
let asset = release
.assets
.iter()
.find(|asset| asset.name == asset_name)
.ok_or_else(|| format!("no asset found matching {:?}", asset_name))?;
let version_dir = format!("clojure-lsp-{}", release.version);
let binary_path = format!("{version_dir}/clojure-lsp");
if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) {
zed::set_language_server_installation_status(
language_server_id,
&zed::LanguageServerInstallationStatus::Downloading,
);
zed::download_file(
&asset.download_url,
&version_dir,
zed::DownloadedFileType::Zip,
)
.map_err(|e| format!("failed to download file: {e}"))?;
let entries =
fs::read_dir(".").map_err(|e| format!("failed to list working directory {e}"))?;
for entry in entries {
let entry = entry.map_err(|e| format!("failed to load directory entry {e}"))?;
if entry.file_name().to_str() != Some(&version_dir) {
fs::remove_dir_all(entry.path()).ok();
}
}
}
self.cached_binary_path = Some(binary_path.clone());
Ok(binary_path)
}
}
impl zed::Extension for ClojureExtension {
fn new() -> Self {
Self {
cached_binary_path: None,
}
}
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::new(),
env: Default::default(),
})
}
}
zed::register_extension!(ClojureExtension);

View file

@ -28,8 +28,6 @@ extend-exclude = [
# Editor and file finder rely on partial typing and custom in-string syntax. # Editor and file finder rely on partial typing and custom in-string syntax.
"crates/file_finder/src/file_finder_tests.rs", "crates/file_finder/src/file_finder_tests.rs",
"crates/editor/src/editor_tests.rs", "crates/editor/src/editor_tests.rs",
# Clojure uses .edn filename extension, which is not a misspelling of "end".
"extensions/clojure/languages/clojure/config.toml",
# There are some names in the test data that are incorrectly flagged as typos. # There are some names in the test data that are incorrectly flagged as typos.
"crates/git/test_data/blame_incremental_complex", "crates/git/test_data/blame_incremental_complex",
"crates/git/test_data/golden/blame_incremental_complex.json", "crates/git/test_data/golden/blame_incremental_complex.json",