| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | use zed_extension_api::{self as zed, LanguageServerId, Result}; |
| 9 | |
| 10 | struct EntsExtension; |
| 11 | |
| 12 | pub(crate) static BIN_NAME: &str = |
| 13 | "/Users/joey/Workspace/codes/git/ents/git-ents/target/debug/git-ents"; |
| 14 | |
| 15 | impl 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 | |
| 37 | zed::register_extension!(EntsExtension); |