
This PR changes the interface of ContextProvider, allowing it to inspect *all* variables set so far during the process of building `TaskVariables`. This makes it possible to capture e.g. an identifier in tree-sitter query, process it and then export it as a task variable. Notably, the list of variables includes captures prefixed with leading underscore; they are removed after all calls to `build_context`, but it makes it possible to capture something and then conditionally preserve it (and perhaps modify it). Release Notes: - N/A
17 lines
619 B
Rust
17 lines
619 B
Rust
use project::ContextProviderWithTasks;
|
|
use task::{TaskTemplate, TaskTemplates, VariableName};
|
|
|
|
pub(super) fn bash_task_context() -> ContextProviderWithTasks {
|
|
ContextProviderWithTasks::new(TaskTemplates(vec![
|
|
TaskTemplate {
|
|
label: "execute selection".to_owned(),
|
|
command: VariableName::SelectedText.template_value(),
|
|
..TaskTemplate::default()
|
|
},
|
|
TaskTemplate {
|
|
label: format!("run '{}'", VariableName::File.template_value()),
|
|
command: VariableName::File.template_value(),
|
|
..TaskTemplate::default()
|
|
},
|
|
]))
|
|
}
|