tasks: Add experimental support for user-defined task variables (#13699)

Context:
@bennetbo spotted a regression in handling of `cargo run` task in zed
repo following a merge of #13658. We've started invoking `cargo run`
from the folder of an active file whereas previously we did it from the
workspace root. We brainstormed few solutions that involved adding a
separate task that gets invoked at a workspace level, but I realized
that a cleaner solution may be to finally add user-configured task
variables. This way, we can choose which crate to run by default at a
workspace level.

This has been originally brought up in the context of javascript tasks
in
https://github.com/zed-industries/zed/pull/12118#issuecomment-2129232114

Note that this is intended for internal use only for the time being.
/cc @RemcoSmitsDev we should be unblocked on having runner-dependant
tasks now.

Release notes:

- N/A
This commit is contained in:
Piotr Osiewicz
2024-07-01 15:59:19 +02:00
committed by GitHub
parent 065ab93ca7
commit bac6e2fee7
10 changed files with 108 additions and 25 deletions
+6 -1
View File
@@ -1,5 +1,6 @@
use anyhow::Result;
use async_trait::async_trait;
use gpui::AppContext;
use language::{ContextProvider, LanguageServerName, LspAdapter, LspAdapterDelegate};
use lsp::LanguageServerBinary;
use node_runtime::NodeRuntime;
@@ -220,7 +221,11 @@ impl ContextProvider for PythonContextProvider {
Ok(task::TaskVariables::from_iter([unittest_target]))
}
fn associated_tasks(&self) -> Option<TaskTemplates> {
fn associated_tasks(
&self,
_: Option<Arc<dyn language::File>>,
_: &AppContext,
) -> Option<TaskTemplates> {
Some(TaskTemplates(vec![
TaskTemplate {
label: "execute selection".to_owned(),