Support tasks from rust-analyzer (#28359)

(and any other LSP server in theory, if it exposes any LSP-ext endpoint
for the same)

Closes https://github.com/zed-industries/zed/issues/16160

* adds a way to disable tree-sitter tasks (the ones from the plugins,
enabled by default) with
```json5
"languages": {
  "Rust": "tasks": {
      "enabled": false
    }
  }
}
```
language settings

* adds a way to disable LSP tasks (the ones from the rust-analyzer
language server, enabled by default) with
```json5
"lsp": {
  "rust-analyzer": {
    "enable_lsp_tasks": false,
  }
}
```

* adds rust-analyzer tasks into tasks modal and gutter:

<img width="1728" alt="modal"
src="https://github.com/user-attachments/assets/22b9cee1-4ffb-4c9e-b1f1-d01e80e72508"
/>

<img width="396" alt="gutter"
src="https://github.com/user-attachments/assets/bd818079-e247-4332-bdb5-1b7cb1cce768"
/>


Release Notes:

- Added tasks from rust-analyzer
This commit is contained in:
Kirill Bulatov 2025-04-08 15:07:56 -06:00 committed by GitHub
parent 763cc6dba3
commit 39c98ce882
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 882 additions and 201 deletions

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::path::Path;
use collections::HashMap;
use debugger_ui::Start;
use editor::Editor;
use feature_flags::{Debugger, FeatureFlagViewExt};
@ -313,6 +313,17 @@ fn task_contexts(workspace: &Workspace, window: &mut Window, cx: &mut App) -> Ta
})
});
let lsp_task_sources = active_editor
.as_ref()
.map(|active_editor| active_editor.update(cx, |editor, cx| editor.lsp_task_sources(cx)))
.unwrap_or_default();
let latest_selection = active_editor.as_ref().map(|active_editor| {
active_editor.update(cx, |editor, _| {
editor.selections.newest_anchor().head().text_anchor
})
});
let mut worktree_abs_paths = workspace
.worktrees(cx)
.filter(|worktree| is_visible_directory(worktree, cx))
@ -325,6 +336,9 @@ fn task_contexts(workspace: &Workspace, window: &mut Window, cx: &mut App) -> Ta
cx.background_spawn(async move {
let mut task_contexts = TaskContexts::default();
task_contexts.lsp_task_sources = lsp_task_sources;
task_contexts.latest_selection = latest_selection;
if let Some(editor_context_task) = editor_context_task {
if let Some(editor_context) = editor_context_task.await {
task_contexts.active_item_context =