git-ents.gitmain
⌘K
foforge
lib.rs37 lines · 1.0 KB · rusthistorycomment on this file
1//! Zed extension registering `ents-lsp`, the `git ents lsp` language server.
2//!
3//! The extension does no downloading and bundles no binary: `git ents lsp`
4//! is resolved from `$PATH`, exactly as `git-ents` itself is a `git`
5//! subcommand resolved from `$PATH`. See `docs/spec/lens.adoc` (`lens.serve`)
6//! for the contract this server implements.
7
8use zed_extension_api::{self as zed, LanguageServerId, Result};
9
10struct EntsExtension;
11
12pub(crate) static BIN_NAME: &str =
13 "/Users/joey/Workspace/codes/git/ents/git-ents/target/debug/git-ents";
14
15impl zed::Extension for EntsExtension {
16 fn new() -> Self {
17 Self
18 }
19
20 fn language_server_command(
21 &mut self,
22 _language_server_id: &LanguageServerId,
23 worktree: &zed::Worktree,
24 ) -> Result<zed::Command> {
25 let command = worktree
26 .which(BIN_NAME)
27 .ok_or_else(|| format!("`{}` not found on `$PATH`", BIN_NAME))?;
28
29 Ok(zed::Command {
30 command,
31 args: vec!["lsp".into()],
32 env: Default::default(),
33 })
34 }
35}
36
37zed::register_extension!(EntsExtension);