extension: Add capabilities for the process API (#26224)

This PR adds support for capabilities for the extension process API.

In order to use the process API, an extension must declare which
commands it wants to use, with arguments:

```toml
[[capabilities]]
kind = "process:exec"
command = "echo"
args = ["hello!"]
```

A `*` can be used to denote a single wildcard in the argument list:

```toml
[[capabilities]]
kind = "process:exec"
command = "echo"
args = ["*"]
```

And `**` can be used to denote a wildcard for the remaining arguments:

```toml
[[capabilities]]
kind = "process:exec"
command = "ls"
args = ["-a", "**"]
```

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Marshall Bowers 2025-03-06 11:55:00 -05:00 committed by GitHub
parent 99216acdec
commit 6fd9708eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 170 additions and 1 deletions

View file

@ -13,3 +13,8 @@ language = "Gleam"
[grammars.gleam]
repository = "https://github.com/gleam-lang/tree-sitter-gleam"
commit = "8432ffe32ccd360534837256747beb5b1c82fca1"
[[capabilities]]
kind = "process:exec"
command = "echo"
args = ["hello!"]

View file

@ -1,6 +1,7 @@
use std::fs;
use zed::lsp::CompletionKind;
use zed::{CodeLabel, CodeLabelSpan, LanguageServerId};
use zed_extension_api::process::Command;
use zed_extension_api::{self as zed, Result};
struct TestExtension {
@ -13,6 +14,10 @@ impl TestExtension {
language_server_id: &LanguageServerId,
_worktree: &zed::Worktree,
) -> Result<String> {
let echo_output = Command::new("echo").arg("hello!").output()?;
println!("{}", String::from_utf8_lossy(&echo_output.stdout));
if let Some(path) = &self.cached_binary_path {
if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
return Ok(path.clone());