-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Tasks in Zed #7108
Comments
Hey, here's a quick update on the matter;
I expect us to revisit the core implementation at some point as we get closer to the MVP; particularly, we still need to figure out/facilitate runnable duplication. Implementing a different Source than a StaticSource should make for a good stress test of it. |
Another extension worth looking into is allowing one-off runnables spawned from command palette (or some other modal) as described in #7460 ; it's just another source of runnables. |
Yesterday in discussion with @maxbrunsfeld we came to the following conclusions regarding runnables:
|
I've logged some design considirations around tasks a while back in microsoft/language-server-protocol#944, this might be interesting, even if not particularly useful. |
Initial step for static runnables had been implemented here: #8009
Future dynamic runnables plan is to work on tree-sitter queries and determine tests with their help — should work for Rust, where r-a detects those as "something in derive macro declaration, that contains the word |
Part of #7108 This PR includes just the static runnables part. We went with **not** having a dedicated panel for runnables. This is just a 1st PR out of N, as we want to start exploring the dynamic runnables front. Still, all that work is going to happen once this gets merged. Release Notes: - Added initial, static Runnables support to Zed. Such runnables are defined in `runnables.json` file (accessible via `zed: open runnables` action) and they can be spawned with `runnables: spawn` action. --------- Co-authored-by: Kirill Bulatov <[email protected]> Co-authored-by: Pitor <[email protected]> Co-authored-by: Beniamin <[email protected]>
/cc @SomeoneToIgnore Fixes #7460 and partially addresses #7108 Release Notes: - N/A
Initial tasks implementation has landed in Preview yesterday.
We're now looking towards more dynamic use cases, like running the tests. |
Cool, can you please implement local task definitions (like in the project dir/.zed/tasks)? |
 Follow-up of #7108 (comment) 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
We've just shipped task contexts (#8675) in yesterday's Preview, which expose a small subset of the editor's state to tasks in read-only fashion. |
I think tasks would be even better and more useful if we can chain some together, i.e., one depends on another, similar to VS Code's |
I would like to add two suggestions:
|
Agree! I am doing this to open the repo in Emacs. #8485 (reply in thread) |
This has just been implemented by @SomeoneToIgnore in #9399 =) It should be out with next Preview on Wednesday (assuming we don't release anything sooner). |
So I just tried it in the new Zed Preview. |
@failable You'll want to either change "use_new_terminal" to |
@baldwindavid I've thought setting |
Yes, I have use cases where I'd rather the terminal is not added at all, but the current functionality mixed with keybindings gets us pretty far. Eventually I think it would be nice to be able to configure tasks to handle a number of different scenarios with the concept of a "target". There could be different target types: None (headless)
No terminal is displayed at all (i.e. headless). Terminal Panel
Center Panel
Same settings as the terminal panel, but the addition of...
I touched on this a bit in #9445 |
This feature is really awesome. But I would like an option to kill the tab after the program terminates (maybe only when terminates with no error code?). |
I strongly endorse this feature. This would allow to have something like VScode's LaTeX Workshop. However, this would not replace more active extensions, where exposing also the buffer, search/replace, and grep functionality would be awesome. For instance, there are VSCode extensions that perform all types of manipulations on the text without having to rely on LSP, and porting these would be quite useful. |
This issue seems good to be closed after #10873 is merged, so closing optimistically, as this PR's feature is planned to be done one way or another. Now, Zed has:
This looks like a good place to stop adding new related features and concentrate on polishing the existing functionality, fixing the bugs and straightening out the usability. So far, there are uncertainties about
Notes on future possible plans:
Overall, the remaining scope so far seems relatively small compared to zero tasks we've started with in the beginning, so let's consider the rest of the feedback, features and improvements in the new issues. |
Check for existing issues
Describe the feature
Idea
Provide multiple new user-facing features:
Proposal
#5242 and more questions/mentions under various names.
The idea is to have a way to (re)run various tasks from the editor, either scripted/configured by users or provided by language features (LSP servers, plugins, etc.)
Current situation with tasks outside of Zed
LSP
There's only one "generic" LSP thing for tasks currently:
codeLens
, that may carry an extra command data for the LSP server to run when queried.All other ways to run things are editor-specific and are provided by the editor API.
VSCode draws code lens as phantom text on top of certain elements (defined with the range), occupying extra vertical space.
Code lens could be resolved later, and may not contain any command to run and be just a text "label".
Spec:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens
Some example rust-analyzer sends back to Zed's prototype
The problem with this part of LSP is the facts that running of commands is editor-specific.
In particular, for tasks, there have to be two extra phases done:
every command ID and handler are registered by the editor extension using
vscode.commands.registerCommand
APIThe command handler on the extension side is responsible for deserializing command payload and using
vscode.tasks.executeTask
API to run the constructed task.later, commands are either triggered by the extension via
vscode.commands.executeCommand
API or the editor itself handles code lens clicks and runs the commandIf we want to support those in Zed, we have to manually implement the command deserialization into the task at least, and keep it up to date with the extension code: all command arguments are typeless
json::Value
, and only the extension knows about its structure.Moveover, additional filtering will be needed for certain lens commands like
rust-analyzer.debugSingle
as those rely on more VSCode-specific extensions.Last but not least, code lens support is differently (un)supported in different LSP servers, e.g. typescript-language-server does not provide test task lens as rust-analyzer does.
VSCode
To automatically provide tasks, VSCode extension can use platform API https://code.visualstudio.com/api/extension-guides/task-provider and return a list of tasks, but the extension also can create and trigger certain tasks on the fly (e.g. rust-analyzer extension "run task" command).
Similarly, VSCode extension can run registered commands via VSCode API, effectively invoking a task, converted out of that command by the extension.
VSCode has a separate API for "test browser" that is able to run one or multiple tests
https://code.visualstudio.com/api/extension-guides/testing
Build Server Protocol (BSP) https://build-server-protocol.github.io
It's very raw and current (few) BSP language server do not have tasks for tests.
List of build tools supported currently: https://build-server-protocol.github.io/docs/overview/implementations
note no Python, TS, JS, etc. there.
Spec part for the test tasks: https://build-server-protocol.github.io/docs/specification#buildtargettest-request shows that BSPs are, in theory, capable to build, run various kinds of tests and spawn debug sessions.
Approaching the implementation
Zed supports neither of the above, to avoid future conflicts with the plugin design, it looks more reasonable to develop a minimalistic, standalone feature for now.
Key ideas:
Start with the static tasks
VSCode has this schema for its tasks:
which we can use as an inspiration, simplified, for a task definition for Zed.
In this iteration, the tasks should be able to run user shell commands on the same machine via Zed, and use its serialized form in directory-level and global user configs.
During the implementation, we will have to consider main task-related design questions:
We have to disallow sharing remotely all tasks by default for security reasons, which means extra code on the directory-level config sharing code, is there something else worth considering?
We do not have any established way to grant access to host capabilities, so for now the remote tasks launch seems to be out of scope.
how would tasks be run?
We can create a file_finder-like modal with the task names and an action to spawn it, then we'll be use the keyboard only to spawn the tasks.
Tasks definition may get a config entry for keybindings, but that might need more work around the scopes, but at least we should provide a way to rerun the last task, to be able to run
cargo check
in a loop.With
cargo check
on re-run we can disable the check on save rust-analyzer's feature and make LSP more responsive in collab mode, re-checking only when nedeed on the host.how would tasks be presented onscreen?
Local shell tasks would benefit from a terminal output-like display, with corresponding coloring, cmd+click and other
TerminalElement
features, but is its code in Zed ready for that?We could use a readonly
Editor
as we do in the LSP logs panel, but this may hang due to large (tens of megabytes) amounts of text pushed to it.Based on that decision, the pane for the task output might differ (terminal elements are now allowed only in the terminal pane), but seems that creating another pane with task tabs is a possible way to go.
place to store in Zed data
This has to be at least a project level, to know about the terminal, worktrees and LSP, but potentially a workspace is a better option?
define a
Task
interface (name up to change, but notTask
as occupied by Zed's runtime already)@osiewicz starts on the design and has proposals for doing that as a short-lived definition object (Rust enum), that can be constructed from any other data.
This way, we can keep e.g. lens data in LSP format in some cache, that would be able to emit a list of Tasks on demand, which will go to the corresponding UI elements.
Making tasks more generic
Templatize the static configuration
If Zed provides a good set of
${workspace_path}
,${buffer_path}
, etc. variables.The idea needs evaluation, cargo test runner may be a good attempt to start with.
Support rust-analyzer better
Either of options below brings a need for
TaskProvider
-like logic, which is close to what extensions API needs.Consider Zed plugin API for tasks and tests and if/how BSP can be used there
BSP:
Plugins:
TaskProvider
described above already exists, it seems to be simpler)At this point, it seems enough to take a break and wait for either of the approaches becomes more mature, fixing bugs in the existing tasks support.
Both plugin and BSP require some code to write to support tasks for a language.
Rust BSP can be already attempted, @osiewicz had done some prototype work on it, and I would like to see what it takes to make it on par with rust-analyzer extension's tasks in VSCode.
If applicable, add mockups / screenshots to help present your vision of the feature
No response
The text was updated successfully, but these errors were encountered: