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:
parent
065ab93ca7
commit
bac6e2fee7
10 changed files with 108 additions and 25 deletions
|
@ -120,6 +120,8 @@ pub struct LanguageSettings {
|
|||
pub code_actions_on_format: HashMap<String, bool>,
|
||||
/// Whether to perform linked edits
|
||||
pub linked_edits: bool,
|
||||
/// Task configuration for this language.
|
||||
pub tasks: LanguageTaskConfig,
|
||||
}
|
||||
|
||||
impl LanguageSettings {
|
||||
|
@ -340,6 +342,10 @@ pub struct LanguageSettingsContent {
|
|||
///
|
||||
/// Default: true
|
||||
pub linked_edits: Option<bool>,
|
||||
/// Task configuration for this language.
|
||||
///
|
||||
/// Default: {}
|
||||
pub tasks: Option<LanguageTaskConfig>,
|
||||
}
|
||||
|
||||
/// The contents of the inline completion settings.
|
||||
|
@ -546,6 +552,13 @@ fn scroll_debounce_ms() -> u64 {
|
|||
50
|
||||
}
|
||||
|
||||
/// The task settings for a particular language.
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||
pub struct LanguageTaskConfig {
|
||||
/// Extra task variables to set for a particular language.
|
||||
pub variables: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl InlayHintSettings {
|
||||
/// Returns the kinds of inlay hints that are enabled based on the settings.
|
||||
pub fn enabled_inlay_hint_kinds(&self) -> HashSet<Option<InlayHintKind>> {
|
||||
|
@ -823,6 +836,7 @@ fn merge_settings(settings: &mut LanguageSettings, src: &LanguageSettingsContent
|
|||
src.code_actions_on_format.clone(),
|
||||
);
|
||||
merge(&mut settings.linked_edits, src.linked_edits);
|
||||
merge(&mut settings.tasks, src.tasks.clone());
|
||||
|
||||
merge(
|
||||
&mut settings.preferred_line_length,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::ops::Range;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
|
||||
use crate::{Location, Runnable};
|
||||
|
||||
|
@ -31,7 +31,11 @@ pub trait ContextProvider: Send + Sync {
|
|||
}
|
||||
|
||||
/// Provides all tasks, associated with the current language.
|
||||
fn associated_tasks(&self) -> Option<TaskTemplates> {
|
||||
fn associated_tasks(
|
||||
&self,
|
||||
_: Option<Arc<dyn crate::File>>,
|
||||
_cx: &AppContext,
|
||||
) -> Option<TaskTemplates> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue