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:
parent
99216acdec
commit
6fd9708eee
5 changed files with 170 additions and 1 deletions
|
@ -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!"]
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue