Commit Graph

20 Commits

Author SHA1 Message Date
Piotr Osiewicz
cff9ad19f8
Add spawning of tasks without saving them in the task stack (#9951)
These tasks are not considered for reruns with `task::Rerun`. 
This PR tears a bunch of stuff up around tasks:
- `menu::SecondaryConfirm` for tasks is gonna spawn a task without
storing it in history instead of being occupied by oneshot tasks. This
is done so that cmd-clicking on the menu item actually does something
meaningful.
- `menu::UseSelectedQuery` got moved into picker, as tasks are it's only
user (and it doesn't really make sense as a menu action).

TODO:
- [x] add release note
- [x] Actually implement the core of this feature, which is spawning a
task without saving it in history, lol.

Fixes #9804 
Release Notes:

- Added "fire-and-forget" task spawning; `menu::SecondaryConfirm` in
tasks modal now spawns a task without registering it as the last spawned
task for the purposes of `task::Rerun`. By default you can spawn a task
in this fashion with cmd+enter or by holding cmd and clicking on a task
entry in a list. Spawning oneshots has been rebound to `option-enter`
(under a `picker::ConfirmInput` name). Fixes #9804 (breaking change)
- Moved `menu::UseSelectedQuery` action to `picker` namespace (breaking
change).
2024-03-29 18:41:14 +01:00
Piotr Osiewicz
1360dffead
task: Make UseSelectedQuery modal action expand to full command (#9947)
Previously it expanded to a label, which was correct for oneshots, but
wrong for everything else.

Release Notes:

- Improved UseSelectedQuery (shift-enter) action for tasks modal by
making it substitute a full command and not the task label.
- Fixed one-shot tasks having duplicates in tasks modal.
2024-03-29 11:45:50 +01:00
Piotr Osiewicz
4dc61f7ccd
Extensions registering tasks (#9572)
This PR also introduces built-in tasks for Rust and Elixir. Note that
this is not a precedent for future PRs to include tasks for more
languages; we simply want to find the rough edges with tasks & language
integrations before proceeding to task contexts provided by extensions.

As is, we'll load tasks for all loaded languages, so in order to get
Elixir tasks, you have to open an Elixir buffer first. I think it sort
of makes sense (though it's not ideal), as in the future where
extensions do provide their own tasks.json, we'd like to limit the # of
tasks surfaced to the user to make them as relevant to the project at
hand as possible.

Release Notes:

- Added built-in tasks for Rust and Elixir files.
2024-03-22 16:18:33 +01:00
Piotr Osiewicz
07dbee8651
task: Add ZED_PACKAGE task variable in Rust files. (#9491)
This variable is experimental, as I expect it to be superseded by
whatever the extensions can provide (once we get them)

Release Notes:

- Added experimental ZED_PACKAGE task variable which contains name of
the current crate in Rust files.

---------

Co-authored-by: Kirill <kirill@zed.dev>
2024-03-18 12:18:42 +01:00
Piotr Osiewicz
bf295eac90 Task::spawn now takes an optional task name as an argument.
If it is not set, we fall back to opening a modal. This allows user to spawn tasks via keybind.
2024-03-08 15:28:42 +01:00
Anthony Eid
4c9c9df730
Add ZED_SELECTED_TEXT variable to tasks (#8865)
Tasks are able to access a users selected text using the environment
variable "ZED_SELECTED_TEXT".

Release notes:

- Added ZED_SELECTED_TEXT task variable which contains contents of
selection
2024-03-07 11:59:25 +01:00
Piotr Osiewicz
3a9ec906af
task: make ZED_FILE return abs path, for real this time (#9000)
Release Notes:

- Fixed ZED_FILE environment variable containing a relative path, not an
absolute one.
2024-03-07 11:50:07 +01:00
Marshall Bowers
22fe03913c
Move Clippy configuration to the workspace level (#8891)
This PR moves the Clippy configuration up to the workspace level.

We're using the [`lints`
table](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table)
to configure the Clippy ruleset in the workspace's `Cargo.toml`.

Each crate in the workspace now has the following in their own
`Cargo.toml` to inherit the lints from the workspace:

```toml
[lints]
workspace = true
```

This allows for configuring rust-analyzer to show Clippy lints in the
editor by using the following configuration in your Zed `settings.json`:

```json
{
  "lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "check": {
          "command": "clippy"
        }
      }
    }
  }
```

Release Notes:

- N/A
2024-03-05 12:01:17 -05:00
Piotr Osiewicz
2201b9b116
task: Add task contexts (#8675)
This PR supplements tasks with additional environment variables; ideally
we'll be able to write a task like:
`cargo test -p $ZED_CURRENT_PACKAGE -- $ZED_CURRENT_FUNCTION`
- [x] Flesh out multibuffer interactions
- [x] Add ZED_SYMBOL detection based on tree-sitter queries
- [ ] Add release note and demo
- [x] Figure out a solution for rerun dilemma - should `task: rerun`
reevaluate contexts for tasks?

This PR introduced the following variables:
- ZED_COLUMN - current line column
- ZED_ROW - current line row
and the following, which are available for buffers with associated
files:
- ZED_WORKTREE_ROOT - absolute path to the root of the current worktree.
- ZED_FILE - absolute path to the file
- ZED_SYMBOL - currently selected symbol; should match the last symbol
shown in a symbol breadcrumb (e.g. `mod tests > fn test_task_contexts`
should be equal to ZED_SYMBOL of `test_task_contexts`). Note that this
isn't necessarily a test function or a function at all.

Also, you can use them in `cwd` field of definitions (note though that
we're using https://docs.rs/subst/latest/subst/#features for that, so
don't expect a full shell functionality to work); the syntax should
match up with your typical Unix shell.


Release Notes:

- Added task contexts, which are additional environment variables set by
Zed for task execution; task content is dependent on the state of the
editor at the time the task is spawned.

---------

Co-authored-by: Anthony <anthonyeid7@protonmail.com>
2024-03-04 21:04:53 +01:00
Kirill Bulatov
cdf702aeff
Prompt to save files on recent project selection (#8673) 2024-03-01 18:48:06 +02:00
Kirill Bulatov
b7429bf29d
Added menu::UseSelectedQuery command that populates task modal query with the selected task name (#8572) 2024-02-29 02:20:43 +02:00
Kirill Bulatov
ac30ded80e
Allow .zed/tasks.json local configs (#8536)
![image](https://github.com/zed-industries/zed/assets/2690773/e1511777-b4ca-469e-8636-1e513b615368)

Follow-up of
https://github.com/zed-industries/zed/issues/7108#issuecomment-1960746397

Makes more clear where each task came from, auto (re)load
.zed/config.json changes, properly filtering out other worktree tasks.

Release Notes:

- Added local task configurations
2024-02-29 01:18:13 +02:00
Kirill Bulatov
96d9df073e Sort tasks modal entries by last used time 2024-02-28 14:13:40 +02:00
Dzmitry Malyshau
cb75c57fc0
Cleanup dependencies (part 4) (#8468)
Follow-up to #8425 . Final part - adds the CI check.

Release Notes:
- N/A
2024-02-27 20:41:49 +02:00
Kirill Bulatov
a0c8debd35
Mention possible run options in the task modal placeholder (#8449)
Release Notes:

- Improved run task modal's placeholder

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-02-27 00:04:56 +02:00
Kirill Bulatov
c29ea9bdbc Allow using context in the placeholder_text method 2024-02-25 00:08:57 +02:00
Piotr Osiewicz
0f584cb353
chore: Extract languages from zed crate (#8270)
- Moves languages module from `zed` into a separate crate. That way we
have less of a long pole at the end of compilation.
- Removes moot dependencies on editor/picker. This is totally harmless
and might help in the future if we decide to decouple picker from
editor.

Before:
```
Number of crates that depend on 'picker' but not on 'editor': 1
Total number of crates that depend on 'picker': 13
Total number of crates that depend on 'editor': 30
```
After:
```
Number of crates that depend on 'picker' but not on 'editor': 5
Total number of crates that depend on 'picker': 12
Total number of crates that depend on 'editor': 26
```
The more crates depend on just picker but not editor, the better in that
case.

Release Notes:

- N/A
2024-02-23 15:56:08 +01:00
Thorsten Ball
583d85cf66
Do not add empty tasks to inventory (#8180)
I ran into this when trying out which keybindings work and accidentally
added empty tasks. They get then added to the task inventory and
displayed in the picker.

Release Notes:

- Fixed empty tasks being added to the list of tasks when using `task:
spawn`

---------

Co-authored-by: Kirill <kirill@zed.dev>
2024-02-22 12:21:19 +02:00
Kirill Bulatov
0c939e5dfc
Add task docs and default keybindings (#8123)
Also group task source modules together

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-02-21 16:43:56 +02:00
Kirill Bulatov
2679457b02
Rename runnables into tasks (#8119)
Release Notes:

- N/A
2024-02-21 14:56:43 +02:00