Skip to content

Commit 03f13c9

Browse files
committed
feat: add crystalline support
1 parent 09ae87e commit 03f13c9

File tree

4 files changed

+380
-4
lines changed

4 files changed

+380
-4
lines changed

Cargo.lock

Lines changed: 329 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "zed_crystal"
3+
version = "0.0.1"
4+
edition = "2021"
5+
publish = false
6+
7+
[lib]
8+
path = "src/crystal.rs"
9+
crate-type = ["cdylib"]
10+
11+
[dependencies]
12+
zed_extension_api = "0.1.0"

extension.toml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
authors = ["Margret Riegert <[email protected]>"]
2-
description = "Syntax highlighting for Crystal"
2+
description = "Syntax highlighting and LSP support for Crystal"
33
id = "crystal"
44
name = "Crystal"
55
repository = "https://github.com/crystal-lang-tools/zed-crystal"
66
schema_version = 1
77
version = "0.0.1"
88

9-
[grammars.crystal]
10-
commit = "61cc201c8eb3b6fd4d4eb3e0ac6c303a580eeb6b"
11-
repository = "https://github.com/crystal-lang-tools/tree-sitter"
9+
# Use Ruby grammar for now until Crystal grammar is more complete
10+
[grammars.ruby]
11+
repository = "https://github.com/tree-sitter/tree-sitter-ruby"
12+
commit = "7dbc1e2d0e2d752577655881f73b4573f3fe85d4"
13+
14+
[language_servers.crystalline]
15+
name = "crystalline"
16+
language = "Crystal"
17+
18+
# [grammars.crystal]
19+
# commit = "61cc201c8eb3b6fd4d4eb3e0ac6c303a580eeb6b"
20+
# repository = "https://github.com/crystal-lang-tools/tree-sitter"

src/crystal.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use zed_extension_api::{self as zed, Result};
2+
3+
struct CrystalExtension;
4+
5+
impl zed::Extension for CrystalExtension {
6+
fn new() -> Self {
7+
Self
8+
}
9+
10+
fn language_server_command(
11+
&mut self,
12+
_language_server_id: &zed::LanguageServerId,
13+
worktree: &zed::Worktree,
14+
) -> Result<zed::Command> {
15+
let path = worktree.which("crystalline").ok_or_else(|| {
16+
"Please install crystalline manually and make sure it is on $PATH.".to_string()
17+
})?;
18+
Ok(zed::Command {
19+
command: path,
20+
args: vec![],
21+
env: Default::default(),
22+
})
23+
}
24+
}
25+
26+
zed::register_extension!(CrystalExtension);

0 commit comments

Comments
 (0)