Commit Graph

1608 Commits

Author SHA1 Message Date
Marshall Bowers
13bbaf1e18
Use UpdateGlobal accessors in more places (#11925)
This PR updates a number of instances that were previously using
`cx.update_global` to use `UpdateGlobal::update_global` instead.

Release Notes:

- N/A
2024-05-16 13:30:04 -04:00
Thorsten Ball
8c681d0db3
lsp: Use itemDefaults if sent along with completion items (#11902)
This fixes #10532 by properly making use of `itemDefaults.data` when
that is sent along next to completion `items`.

With this line here we tell the language server that we support `data`
in `itemDefaults`, but we actually never checked for it and never used
it:


a0d7ec9f8e/crates/lsp/src/lsp.rs (L653)

In the case of `tailwindcss-language-server` that means that most of the
items it returns (more than 10k items!) were missing the `data`
attribute, since the language server thought it can send it along in the
`itemDefaults` (because we advertised our capability to use it.)

When we then did a `completionItem/resolve`, we would not send a `data`
attribute along, which lead to an error on the
`tailwindcss-language-server` side and thus no documentation.

This PR also adds support for the other `itemDefaults` that could be
sent along and that we say we support:


a0d7ec9f8e/crates/lsp/src/lsp.rs (L650-L653)

`editRange` we handle separately, so this PR only adds the other 3.

Release Notes:

- Fixed documentation not showing up for completion items coming from
`tailwindcss-language-server`.
([#10532](https://github.com/zed-industries/zed/issues/10532)).

Demo:


https://github.com/zed-industries/zed/assets/1185253/bc5ea0b3-7d83-499f-a908-b0d2a1db8a41
2024-05-16 13:26:07 +02:00
Kirill Bulatov
cb430fc3e4
Autodetect parser name with prettier by default (#11558)
Closes https://github.com/zed-industries/zed/issues/11517 

* Removes forced prettier parser name for languages, making `auto`
command to run prettier on every file by default.
* Moves prettier configs away from plugin language declarations into
language settings

Release Notes:

- N/A
2024-05-15 22:51:46 +03:00
Piotr Osiewicz
1db136ff65
tasks: Refresh available tasks in editor when tasks.json changes (#11811)
Release Notes:

- N/A
2024-05-14 21:26:35 +02:00
Thorsten Ball
db89353193
git: Support git repos with .git folder above project root (#11550)
TODOs:

- [x] Add assertions to the test to ensure that the git status is
propagated
- [x] Get collaboration working
- [x] Test opening a git repository inside another git repository
- [x] Test opening the sub-folder of a repository that itself contains
another git repository in a subfolder

Fixes:
- Fixes https://github.com/zed-industries/zed/issues/10154
- Fixes https://github.com/zed-industries/zed/issues/8418
- Fixes https://github.com/zed-industries/zed/issues/8275
- Fixes https://github.com/zed-industries/zed/issues/7816
- Fixes https://github.com/zed-industries/zed/issues/6762
- Fixes https://github.com/zed-industries/zed/issues/4419
- Fixes https://github.com/zed-industries/zed/issues/4672
- Fixes https://github.com/zed-industries/zed/issues/5161

Release Notes:

- Added support for opening subfolders of git repositories and treating
them as part of a repository (show git status in project panel, show git
diff in gutter, git blame works, ...)
([#4672](https://github.com/zed-industries/zed/issues/4672)).

Demo video:


https://github.com/zed-industries/zed/assets/1185253/afc1cdc3-372c-404e-99ea-15708589251c
2024-05-14 18:34:51 +02:00
Piotr Osiewicz
95e0d5ed74
tasks: Reorganize task modal (#11752)
![image](https://github.com/zed-industries/zed/assets/24362066/bc7cc3d3-d9fc-4be6-b9b6-e3d8edf5b533)

Release Notes:
- Improved tasks modal by highlighting a distinction between a task
template and concrete task instance and surfacing available keybindings
more prominently. Task templates are now always available in the modal,
even if there's already a history entry with the same label.
- Changed default key binding for "picker::UseSelectedQuery" to `opt-e`.
2024-05-14 11:22:09 +02:00
Conrad Irwin
5515ba6043
Extract http from util (#11680)
This avoids the CLI linking libssl etc...

Release Notes:

- N/A
2024-05-10 15:50:20 -06:00
Thorsten Ball
df190ea846
vcs menu: Use project's repositories, do not open directly (#11652)
I ran into this when trying to get #11550 working: the VCS menu would
open repositories on its owned, based on paths, instead of going through
the worktree on which we already store the git repositories.



Release Notes:

- N/A
2024-05-10 11:06:32 +02:00
Max Brunsfeld
a7aa2578e1
Implement serialization of assistant conversations, including tool calls and attachments (#11577)
Release Notes:

- N/A

---------

Co-authored-by: Kyle <kylek@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
2024-05-08 17:52:15 -04:00
LoganDark
45aca348b8
Take local project settings into account when launching terminals (#11526)
Fixes #7599

Use project level settings if possible, when creating terminals.

Release Notes:

- Fixed terminals ignoring project-specific settings ([7599](https://github.com/zed-industries/zed/issues/7599))
2024-05-08 13:39:47 +03:00
Kirill Bulatov
3d9f0087ff
Do not show diffs for files with \r\n contents (#11519) 2024-05-08 00:37:09 +03:00
Piotr Osiewicz
d4636481ac
tasks: Prefer worktree tasks to global tasks in tag selection (#11427)
Release Notes:

- Added test indicators in Rust files, backed by task system.
2024-05-06 16:53:48 +02:00
Kirill Bulatov
1e84f01041
Use lowercased language name as language id fallback (#11412) 2024-05-05 22:27:18 +03:00
Piotr Osiewicz
5a71d8c7f1
Add support for detecting tests in source files, and implement it for Rust (#11195)
Continuing work from #10873 

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-05-05 16:32:48 +02:00
Kyle Kelley
6563330239
Supermaven (#10788)
Adds a supermaven provider for completions. There are various other
refactors amidst this branch, primarily to make copilot no longer a
dependency of project as well as show LSP Logs for global LSPs like
copilot properly.

This feature is not enabled by default. We're going to seek to refine it
in the coming weeks.

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-05-03 12:50:42 -07:00
Kirill Bulatov
b523ee6980
Use Rope instead of String for buffer diff base (#11300)
As an attempt to do things better when showing diff hunks, store diff
base as Rope, not String, to have cheaper clones when the diff base text
is reused, e.g. creating another buffer with the diff base text for hunk
diff expanding.

Release Notes:

- N/A
2024-05-03 11:18:43 +03:00
Conrad Irwin
9bac64a9c1
Rename RemoteProject -> DevServerProject (#11301)
Co-Authored-By: Mikayla <mikayla@zed.dev>

In a fit of ill-advisedness I called these things remote projects;
forgetting that remote project is also what we call collaboratively
shared projects.

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Bennet <bennetbo@gmx.de>
2024-05-02 11:00:08 -06:00
Thorsten Ball
c81230405f
typescript: Complete function calls with snippets (#11157)
This allows function call (i.e. snippet) completion with
`typescript-language-server`. So far that didn't work, because
`typescript-language-server` doesn't respond with `insertText` when
getting the completions, but only when then sending
`completionItem/resolve` requests. See:
https://github.com/hrsh7th/nvim-cmp/issues/646#issuecomment-992765479

What this PR does is to support text edits in the response to
`completionItem/resolve`, which means updating the completion item.

It then enables this feature by default for
`typescript-language-server`.


TODOs:

- [x] Make this work over collab
- [x] Test that this doesn't break existing language server support
- [x] Refactor duplicated code

Release Notes:

- Added support for function call completion when using
`typescript-language-server`. This will result in parameters being
added, which can then be changed and navigated with `<tab>`. For this to
work with `typescript-language-server`, the documentation for a given
completion item needs to be resolved, meaning that if one types very
quickly and accepts completion before `typescript-language-server` could
respond with the documentation, no full function completion is used.

Demo:


https://github.com/zed-industries/zed/assets/1185253/c23ebe12-5902-4b50-888c-d9b8cd32965d
2024-05-02 10:50:01 +02:00
Kirill Bulatov
caa0d35b8b
Allow to toggle git hunk diffs (#11080)
Part of https://github.com/zed-industries/zed/issues/4523

Added two new actions with the default keybindings

```
"cmd-'": "editor::ToggleHunkDiff",
"cmd-\"": "editor::ExpandAllHunkDiffs",
```

that allow to browse git hunk diffs in Zed:


https://github.com/zed-industries/zed/assets/2690773/9a8a7d10-ed06-4960-b4ee-fe28fc5c4768


The hunks are dynamic and alter on user folds and modifications, or
toggle hidden, if the modifications were not adjacent to the expanded
hunk.


Release Notes:

- Added `editor::ToggleHunkDiff` (`cmd-'`) and
`editor::ExpandAllHunkDiffs` (`cmd-"`) actions to browse git hunk diffs
in Zed
2024-05-01 22:47:36 +03:00
Conrad Irwin
3752ed294d
open new buffer (#11203)
Release Notes:

- Allow creating new untitled buffers in remote projects

TODO:
- Add a Test
- Fix version number check
2024-04-30 16:09:43 -06:00
Conrad Irwin
cb7350174e
Don't allow dropping files on remote projects (#11218)
Release Notes:

- Fixed a panic when a remote participant dropped a local file on your
project
2024-04-30 14:24:47 -06:00
Thorsten Ball
73d0600ad2
project: Set completion to undocumented if text empty (#11207)
I think the previous code was missing a `return` in there because it
always overwrote the `completion.documentation` field, even if the
`text.is_empty()` is true.

Release Notes:

- N/A
2024-04-30 14:56:22 +02:00
Mikayla Maki
d2569afe66
Switch from delete file by default to trash file by default (#10875)
TODO:

- [x] Don't immediately seg fault
- [x] Implement for directories 
- [x] Add cmd-delete to remove files
- [ ] ~~Add setting for trash vs. delete~~ You can just use keybindings
to change the behavior.

fixes https://github.com/zed-industries/zed/issues/7228
fixes https://github.com/zed-industries/zed/issues/5094

Release Notes:

- Added a new `project_panel::Trash` action and changed the default
behavior for `backspace` and `delete` in the project panel to send a
file to the systems trash, instead of permanently deleting it
([#7228](https://github.com/zed-industries/zed/issues/7228),
[#5094](https://github.com/zed-industries/zed/issues/5094)). The
original behavior can be restored by adding the following section to
your keybindings:

```json5
[
// ...Other keybindings...
  {
    "context": "ProjectPanel",
    "bindings": {
        "backspace": "project_panel::Delete",
        "delete": "project_panel::Delete",
    }
  }
]
2024-04-26 17:43:50 -07:00
Conrad Irwin
664f779eb4
new path picker (#11015)
Still TODO:

* Disable the new save-as for local projects
* Wire up sending the new path to the remote server

Release Notes:

- Added the ability to "Save-as" in remote projects

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Bennet <bennetbo@gmx.de>
2024-04-26 13:25:25 -06:00
Max Brunsfeld
40fe5275cf
Rework project diagnostics to prevent showing inconsistent state (#10922)
For a long time, we've had problems where diagnostics can end up showing
up inconsistently in different views. This PR is my attempt to prevent
that, and to simplify the system in the process. There are some UX
changes.

Diagnostic behaviors that have *not* changed:

* In-buffer diagnostics update immediately when LSPs send diagnostics
updates.
* The diagnostic counts in the status bar indicator also update
immediately.

Diagnostic behaviors that this PR changes:

* [x] The tab title for the project diagnostics view now simply shows
the same counts as the status bar indicator - the project's current
totals. Previously, this tab title showed something slightly different -
the numbers of diagnostics *currently shown* in the diagnostics view's
excerpts. But it was pretty confusing that you could sometimes see two
different diagnostic counts.
* [x] The project diagnostics view **never** updates its excerpts while
the user might be in the middle of typing it that view, unless the user
expressed an intent for the excerpts to update (by e.g. saving the
buffer). This was the behavior we originally implemented, but has
changed a few times since then, in attempts to fix other issues. I've
restored that invariant.

    Times when the excerpts will update:
     * diagnostics are updated while the diagnostics view is not focused
     * the user changes focus away from the diagnostics view
* the language server sends a `work done progress end` message for its
disk-based diagnostics token (i.e. cargo check finishes)
* the user saves a buffer associated with a language server, and then a
debounce timer expires

* [x] The project diagnostics view indicates when its diagnostics are
stale. States:
* when diagnostics have been updated while the diagnostics view was
focused:
        * the indicator shows a 'refresh' icon
        * clicking the indicator updates the excerpts
* when diagnostics have been updated, but a file has been saved, so that
the diagnostics will soon update, the indicator is disabled

With these UX changes, the only 'complex' part of the our diagnostics
presentation is the Project Diagnostics view's excerpt management,
because it needs to implement the deferred updates in order to avoid
disrupting the user while they may be typing. I want to take some steps
to reduce the potential for bugs in this view.

* [x] Reduce the amount of state that the view uses, and simplify its
implementation
* [x] Add a randomized test that checks the invariant that a mutated
diagnostics view matches a freshly computed diagnostics view


##  Release Notes

- Reworked the project diagnostics view:
- Fixed an issue where the project diagnostics view could update its
excerpts while you were typing in it.
- Fixed bugs where the project diagnostics view could show the wrong
excerpts.
- Changed the diagnostics view to always update its excerpts eagerly
when not focused.
- Added an indicator to the project diagnostics view's toolbar, showing
when diagnostics have been changed.

---------

Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2024-04-25 18:12:15 -07:00
Marshall Bowers
3eac581a62
Allow controlling Tailwind via the language_servers setting (#11012)
This PR adds the ability for the Tailwind language server
(`tailwindcss-language-server`) to be controlled by the
`language_servers` setting.

Now in your settings you can indicate that the Tailwind language server
should be used for a given language, even if that language does not have
the Tailwind language server registered for it already:

```json
{
  "languages": {
    "My Language": {
      "language_servers": ["tailwindcss-language-server", "..."]
    }
  }
}
```

Release Notes:

- N/A
2024-04-25 17:29:47 -04:00
Marshall Bowers
d8437136c7
Fix primary language server selection for formatting (#10939)
This PR fixes the way we select the primary language server for use with
formatting.

Previously we were just taking the first one in the list, but this could
be the wrong one in cases where a language server was provided by an
extension in conjunction with a built-in language server (e.g.,
Tailwind).

We now use the `primary_language_server_for_buffer` method to more
accurately identify the primary one.

Fixes https://github.com/zed-industries/zed/issues/10902.

Release Notes:

- Fixed an issue where the wrong language server could be used for
formatting.
2024-04-24 12:42:33 -04:00
Marshall Bowers
76ff467965
Log which language servers will be started (#10936)
This PR adds a new log message indicating which language servers will be
started for a given language.

The aim is to make debugging the usage of the new `language_servers`
setting (#10911) easier.

Release Notes:

- N/A
2024-04-24 11:22:42 -04:00
Marshall Bowers
cf67fc9055
Add language_servers setting for customizing which language servers run (#10911)
This PR adds a new `language_servers` setting underneath the language
settings.


This setting controls which of the available language servers for a
given language will run.

The `language_servers` setting is an array of strings. Each item in the
array must be either:

- A language server ID (e.g., `"rust-analyzer"`,
`"typescript-language-server"`, `"eslint"`, etc.) denoting a language
server that should be enabled.
- A language server ID prefixed with a `!` (e.g., `"!rust-analyzer"`,
`"!typescript-language-server"`, `"!eslint"`, etc.) denoting a language
server that should be disabled.
- A `"..."` placeholder, which will be replaced by the remaining
available language servers that haven't already been mentioned in the
array.

For example, to enable the Biome language server in place of the default
TypeScript language server, you would add the following to your
settings:

```json
{
  "languages": {
    "TypeScript": {
      "language_servers": ["biome", "!typescript-language-server", "..."]
    }
  }
}
```

More details can be found in #10906.

Release Notes:

- Added `language_servers` setting to language settings for customizing
which language server(s) run for a given language.
2024-04-23 19:38:57 -04:00
Conrad Irwin
e0c83a1d32
remote projects per user (#10594)
Release Notes:

- Made remote projects per-user instead of per-channel. If you'd like to
be part of the remote development alpha, please email hi@zed.dev.

---------

Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
Co-authored-by: Bennet <bennetbo@gmx.de>
Co-authored-by: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
Co-authored-by: Nate Butler <iamnbutler@gmail.com>
2024-04-23 15:33:09 -06:00
Kirill Bulatov
dd41c10099
Filter out other languages' tasks from the task modal (#10839)
Release Notes:

- Fixed tasks modal showing history from languages, not matching the
currently active buffer's one
2024-04-22 12:36:26 +03:00
Kirill Bulatov
13c17267b9
Properly pass nested script arguments for tasks (#10776)
Closes
https://github.com/zed-industries/zed/discussions/10732#discussion-6524347
introduced by https://github.com/zed-industries/zed/pull/10548 while
keeping both Python and Bash run selection capabilities.

Also replaced redundant `SpawnTask` struct with `SpawnInTerminal` that
has identical fields.

Release Notes:

- Fixed incorrect task escaping of nested script arguments

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
2024-04-19 16:24:35 +03:00
Piotr Osiewicz
3273f5e404
fs: Move Repository trait into git crate (#10768)
/cc @mrnugget 
Release Notes:

- N/A
2024-04-19 11:57:17 +02:00
Thorsten Ball
c2428f9f5d
git blame: Parse permalinks client side (#10714)
Release Notes:

- N/A
2024-04-18 12:36:22 +02:00
Shreekar Halvi
bb97432e9a
Add minimum column option to git inline blame (#10682)
Release Notes:

- Added a setting to determine the minimum column where the inline blame
information is shown. Example: `{{"git": {"inline_blame": {"min_column":
80}}}` ([#10555](https://github.com/zed-industries/zed/issues/10555)).

Demo Video:


https://github.com/zed-industries/zed/assets/1185253/61343dbe-9002-4bd1-b0d4-403f8da79050

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-04-18 11:28:47 +02:00
Kirill Bulatov
be2bf98529
Show task summary in its terminal after it stops running (#10615)
Based on https://github.com/alacritty/alacritty/issues/7795

Unknown error code commands (now includes the interrupted ones):

![image](https://github.com/zed-industries/zed/assets/2690773/801868bc-081c-453c-a353-233d4397bda9)

Successful command:

![image](https://github.com/zed-industries/zed/assets/2690773/874377c7-c967-4a6f-8a89-ec7bf398a8b3)

Unsuccessful command:

![image](https://github.com/zed-industries/zed/assets/2690773/6c99dc5d-d324-41e9-a71b-5d0bf705de27)

The "design", including wordings and special characters, is not final,
suggestions are welcome.
The main idea was to somehow distinguish the appended lines without
occupying extra vertical space.

Release Notes:

- Added task summary output into corresponding terminal tabs
2024-04-16 22:13:35 +03:00
Thorsten Ball
c015b5c4cd
Enable inline-git-blame by default (#10632)
Release Notes:

- N/A
2024-04-16 18:53:57 +02:00
Kirill Bulatov
57b087e41e
On label conflict, prefer resolved tasks with never templates (#10586)
This way, static (and other) templates that change, e.g. env vars, will
get the new template resolved task in the modal to run.

Release Notes:

- N/A
2024-04-16 03:31:33 +03:00
Kirill Bulatov
db48c75231
Add basic bash and Python tasks (#10548)
Part of https://github.com/zed-industries/zed/issues/5141

* adds "run selection" and "run file" tasks for bash and Python.
* replaces newlines with `\n` symbols in the human-readable task labels
* properly escapes task command arguments when spawning the task in
terminal

Caveats:

* bash tasks will always use user's default shell to spawn the
selections, but they should rather respect the shebang line even if it's
not selected
* Python tasks will always use `python3` to spawn its tasks now, as
there's no proper mechanism in Zed to deal with different Python
executables

Release Notes:

- Added tasks for bash and Python to execute selections and open files
in terminal
2024-04-15 16:07:21 +03:00
Thorsten Ball
faebce8cd0
Inline git blame (#10398)
This adds so-called "inline git blame" to the editor that, when turned
on, shows `git blame` information about the current line inline:


![screenshot-2024-04-15-11 29
35@2x](https://github.com/zed-industries/zed/assets/1185253/21cef7be-3283-4556-a9f0-cc349c4e1d75)


When the inline information is hovered, a new tooltip appears that
contains more information on the current commit:


![screenshot-2024-04-15-11 28
24@2x](https://github.com/zed-industries/zed/assets/1185253/ee128460-f6a2-48c2-a70d-e03ff90a737f)

The commit message in this tooltip is rendered as Markdown, is
scrollable and clickable.

The tooltip is now also the tooltip used in the gutter:

![screenshot-2024-04-15-11 28
51@2x](https://github.com/zed-industries/zed/assets/1185253/42be3d63-91d0-4936-8183-570e024beabe)


## Settings

1. The inline git blame information can be turned on and off via
settings:
```json
{
  "git": {
    "inline_blame": {
      "enabled": true
    }
  }
}
```
2. Optionally, a delay can be configured. When a delay is set, the
inline blame information will only show up `x milliseconds` after a
cursor movement:
```json
{
  "git": {
    "inline_blame": {
      "enabled": true,
      "delay_ms": 600
    }
  }
}
```
3. It can also be turned on/off for the current buffer with `editor:
toggle git blame inline`.

## To be done in follow-up PRs

- [ ] Add link to pull request in tooltip
- [ ] Add avatars of users if possible

## Release notes

Release Notes:

- Added inline `git blame` information the editor. It can be turned on
in the settings with `{"git": { "inline_blame": "on" } }` for every
buffer or, temporarily for the current buffer, with `editor: toggle git
blame inline`.
2024-04-15 14:21:52 +02:00
Kirill Bulatov
28586060a1
Display more specific tasks above in the modal (#10485) 2024-04-12 20:19:11 +02:00
Kyle Kelley
49371b44cb
Semantic Index (#10329)
This introduces semantic indexing in Zed based on chunking text from
files in the developer's workspace and creating vector embeddings using
an embedding model. As part of this, we've created an embeddings
provider trait that allows us to work with OpenAI, a local Ollama model,
or a Zed hosted embedding.

The semantic index is built by breaking down text for known
(programming) languages into manageable chunks that are smaller than the
max token size. Each chunk is then fed to a language model to create a
high dimensional vector which is then normalized to a unit vector to
allow fast comparison with other vectors with a simple dot product.
Alongside the vector, we store the path of the file and the range within
the document where the vector was sourced from.

Zed will soon grok contextual similarity across different text snippets,
allowing for natural language search beyond keyword matching. This is
being put together both for human-based search as well as providing
results to Large Language Models to allow them to refine how they help
developers.

Remaining todo:

* [x] Change `provider` to `model` within the zed hosted embeddings
database (as its currently a combo of the provider and the model in one
name)


Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Conrad Irwin <conrad@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Co-authored-by: Antonio <antonio@zed.dev>
2024-04-12 11:40:59 -06:00
Conrad Irwin
dffddaec4c
Revert "Revert "language: Remove buffer fingerprinting (#9007)"" (#9671)
This reverts commit caed275fbf.

NOTE: this should not be merged until #9668 is on stable and the
`ZedVersion#can_collaborate` is updated to exclude all clients without
that change.

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-04-12 18:40:35 +02:00
Piotr Osiewicz
a1cbc23fee
task: use full task label to distinguish a terminal (#10469)
Spotted by @SomeoneToIgnore, in #10468 I've used a shortened task label,
which might lead to collisions.

Release Notes:

- N/A
2024-04-12 13:25:46 +02:00
Mehmet Efe Akça
29a50573a9
Add git blame error reporting with notification (#10408)
<img width="1035" alt="Screenshot 2024-04-11 at 13 13 44"
src="https://github.com/zed-industries/zed/assets/13402668/cd0e96a0-41c6-4757-8840-97d15a75c511">

Release Notes:

- Added a notification to show possible `git blame` errors if it fails to run.

Caveats:
- ~git blame now executes in foreground
executor  (required since the Fut is !Send)~

TODOs:
- After a failed toggle, the app thinks the blame
is shown. This means toggling again will do nothing
instead of retrying. (Caused by editor.show_git_blame
being set to true before the git blame is generated)
- ~(Maybe) Trim error?~ Done

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-04-12 07:20:34 +02:00
Max Brunsfeld
8d7f5eab79
Extract Ocaml language support into an extension (#10450)
Release Notes:

- Extracted Ocaml language support into an extension

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-11 15:20:19 -07:00
Conrad Irwin
f6c85b28d5
WIP: remoting (#10085)
Release Notes:

- Added private alpha support for remote development. Please reach out to hi@zed.dev if you'd like to be part of shaping this feature.
2024-04-11 15:36:35 -06:00
Joseph T. Lyons
eb6f7c1240
Remove if-not-else patterns (#10402) 2024-04-11 03:48:06 -04:00
Kirill Bulatov
d1ad96782c
Rework task modal (#10341)
New list (used tasks are above the separator line, sorted by the usage
recency), then all language tasks, then project-local and global tasks
are listed.
Note that there are two test tasks (for `test_name_1` and `test_name_2`
functions) that are created from the same task template:
<img width="563" alt="Screenshot 2024-04-10 at 01 00 46"
src="https://github.com/zed-industries/zed/assets/2690773/7455a82f-2af2-47bf-99bd-d9c5a36e64ab">

Tasks are deduplicated by labels, with the used tasks left in case of
the conflict with the new tasks from the template:
<img width="555" alt="Screenshot 2024-04-10 at 01 01 06"
src="https://github.com/zed-industries/zed/assets/2690773/8f5a249e-abec-46ef-a991-08c6d0348648">

Regular recent tasks can be now removed too:
<img width="565" alt="Screenshot 2024-04-10 at 01 00 55"
src="https://github.com/zed-industries/zed/assets/2690773/0976b8fe-b5d7-4d2a-953d-1d8b1f216192">

When the caret is in the place where no function symbol could be
retrieved, no cargo tests for function are listed in tasks:
<img width="556" alt="image"
src="https://github.com/zed-industries/zed/assets/2690773/df30feba-fe27-4645-8be9-02afc70f02da">


Part of https://github.com/zed-industries/zed/issues/10132
Reworks the task code to simplify it and enable proper task labels.

* removes `trait Task`, renames `Definition` into `TaskTemplate` and use
that instead of `Arc<dyn Task>` everywhere
* implement more generic `TaskId` generation that depends on the
`TaskContext` and `TaskTemplate`
* remove `TaskId` out of the template and only create it after
"resolving" the template into the `ResolvedTask`: this way, task
templates, task state (`TaskContext`) and task "result" (resolved state)
are clearly separated and are not mixed
* implement the logic for filtering out non-related language tasks and
tasks that have non-resolved Zed task variables
* rework Zed template-vs-resolved-task display in modal: now all reruns
and recently used tasks are resolved tasks with "fixed" context (unless
configured otherwise in the task json) that are always shown, and Zed
can add on top tasks with different context that are derived from the
same template as the used, resolved tasks
* sort the tasks list better, showing more specific and least recently
used tasks higher
* shows a separator between used and unused tasks, allow removing the
used tasks same as the oneshot ones
* remote the Oneshot task source as redundant: all oneshot tasks are now
stored in the inventory's history
* when reusing the tasks as query in the modal, paste the expanded task
label now, show trimmed resolved label in the modal
* adjusts Rust and Elixir task labels to be more descriptive and closer
to bash scripts

Release Notes:

- Improved task modal ordering, run and deletion capabilities
2024-04-11 02:02:04 +03:00
Nathan Sobo
7abb63cfda
Improve the ergonomics of creating local buffers (#10347)
This PR renames `language::Buffer::new` to `language::Buffer::local` and
simplifies its interface. Instead of taking a replica id (which should
always be 0 for the local case) and a `BufferId`, which was awkward and
verbose to construct, it simply takes text and a `cx`.

It uses the `cx` to derive a `BufferId` from the `EntityId` associated
with the `cx`, which should always be positive based on the following
analysis...

We convert the entity id to a u64 using this method on `EntityId`, which
is defined by macros in the `slotmap` crate:

```rust
    pub fn as_ffi(self) -> u64 {
        (u64::from(self.version.get()) << 32) | u64::from(self.idx)
    }
```

If you look at the type of `version` in `KeyData`, it is non-zero:

```rust
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KeyData {
    idx: u32,
    version: NonZeroU32,
}
```

This commit also adds `Context::reserve_model` and
`Context::insert_model` to determine a model's entity ID before it is
created, which we need in order to assign a `BufferId` in the background
when loading a buffer asynchronously.

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-04-10 08:32:51 -06:00
Max Brunsfeld
6b320b9efe
Fix cleanup of LSP request status messages (#10336)
This fixes a bug in https://github.com/zed-industries/zed/pull/9818,
where the status was not removed if the request failed. It also adds
replication of these new status messages to guests when collaborating.

Release Notes:

- Fixed an issue where the status of failed LSP actions was left in the
status bar

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-09 17:34:51 -04:00
Marshall Bowers
7c5bc3c26f
Add the ability for extensions to provide language settings (#10296)
This PR adds the ability for extensions to provide certain language
settings via the language `config.toml`.

These settings are then merged in with the rest of the settings when the
language is loaded from the extension.

The language settings that are available are:

- `tab_size`
- `hard_tabs`
- `soft_wrap`

Additionally, for bundled languages we moved these settings out of the
`settings/default.json` and into their respective `config.toml`s .

For languages currently provided by extensions, we are leaving the
values in the `settings/default.json` temporarily until all released
versions of Zed are able to load these settings from the extension.

---

Along the way we ended up refactoring the `Settings::load` method
slightly, introducing a new `SettingsSources` struct to better convey
where the settings are being loaded from.

This makes it easier to load settings from specific locations/sets of
locations in an explicit way.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-04-08 19:17:12 -04:00
Marshall Bowers
56c0345cf3
Respect language server's capabilities when calling GetReferences (#10285)
This PR makes Zed respect the language server's capabilities when
calling the `GetReferences` command (used in "Find All References",
etc.).

This fixes a crash that could occur when using Zed with Gleam v1.0.

Release Notes:

- Made "Find All References" respect the language server's capabilities.
This fixes some instances where certain language servers would stop
working after receiving a "Find All References" request.

---------

Co-authored-by: Max <max@zed.dev>
2024-04-08 13:38:32 -04:00
Thorsten Ball
87c282d8f1
Send along diagnostics when requesting code actions (#10281)
This fixes #10177 by sending along the correct diagnostics when querying
the language server for diagnostics for a given cursor location.

Turns out that `gopls` takes the `range`, `source`, `message` of the
diagnostics sent along to check whether it has any code actions for the
given location.

Release Notes:

- Fixed "quickfix" code actions that were based on diagnostics not
showing up in Go files.
([#10177](https://github.com/zed-industries/zed/issues/10177)).

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
2024-04-08 17:54:06 +02:00
Daniel Zhu
4944dc9d78
Show status of LSP actions (#9818)
Fixes #4380

Parts im still unsure about:
- [x] where exactly I should call `on_lsp_start`/`on_lsp_end`
- [x] how to handle things better than `let is_references =
TypeId::of::<R>() == TypeId::of::<GetReferences>();`, which feels very
janky
- [x] I want to have the message be something like `"Finding references
to [...]"` instead of just `textDocument/references`, but I'm not sure
how to retrieve the name of the symbol that's being queried
- [ ] I think the bulk of the runtime is occupied by `let result =
language_server.request::<R::LspRequest>(lsp_params).await;`, but since
`ModelContext` isn't passed into it, I'm not sure how to update progress
from within that function
- [x] A good way to disambiguate between multiple calls to the same lsp
function; im currently using the function name itself as the unique
identifier for that request, which could create issues if multiple
`textDocument/references` requests are sent in parallel

Any help with these would be deeply appreciated!

Release Notes:

- Adds a status indicator for LSP actions

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-04-06 19:48:11 -07:00
Mikayla Maki
518cfdbd56
Adjust env parsing to account for multiline env values (#10216)
fixes https://github.com/zed-industries/zed/issues/6012

Release Notes:

- N/A
2024-04-05 19:24:46 -07:00
Kirill Bulatov
7b636d9774
Limit the extension tasks in the modal to current language only (#10207)
Release Notes:

- N/A
2024-04-06 00:18:32 +03:00
Marshall Bowers
c851e6edba
Add language_server_workspace_configuration to extension API (#10212)
This PR adds the ability for extensions to implement
`language_server_workspace_configuration` to provide workspace
configuration to the language server.

We've used the Dart extension as a motivating example for this, pulling
it out into an extension in the process.

Release Notes:

- Removed built-in support for Dart, in favor of making it available as
an extension. The Dart extension will be suggested for download when you
open a `.dart` file.

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-04-05 17:04:07 -04:00
Thorsten Ball
b05aa381aa
Handle old versions of /usr/bin/env when loading shell env (#10202)
This fixes #9786 by using an invocation of `/usr/bin/env` that's
supported by macOS 12.

As it turns out, on macOS 12 (and maybe 13?) `/usr/bin/env` doesn't
support the `-0` flag. In our case it would silently fail, since we
`exit 0` in our shell invocation and because the program we run and
whose exit code we check is the `$SHELL` and not `/usr/bin/env`.

What this change does is to drop the `-0` and instead split the
environment on `\n`. This works even if an environment variable contains
a newline character because that would then be escaped.

Release Notes:

- Fixed Zed not picking up shell environments correctly when running on
macOS 12. ([#9786](https://github.com/zed-industries/zed/issues/9786)).

Co-authored-by: Dave Smith <davesmithsemail@gmail.com>
2024-04-05 15:46:56 +02:00
Marshall Bowers
4a325614f0
Add label_for_symbol to extension API (#10179)
This PR adds `label_for_symbol` to the extension API.

As a motivating example, we implemented `label_for_symbol` for the
Haskell extension.

Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
2024-04-04 15:38:38 -04:00
Marshall Bowers
d306b531c7
Add label_for_completion to extension API (#10175)
This PR adds the ability for extensions to implement
`label_for_completion` to customize completions coming back from the
language server.

We've used the Gleam extension as a motivating example, adding
`label_for_completion` support to it.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2024-04-04 13:56:04 -04:00
Kirill Bulatov
1085642c88
Stricten Zed Task variable API (#10163)
Introduce `VariableName` enum to simplify Zed task templating
management: now all the variables can be looked up statically and can be
checked/modified in a centralized way: e.g. `ZED_` prefix is now added
for all such custom vars.

Release Notes:

- N/A
2024-04-04 16:02:24 +03:00
Thorsten Ball
8e9543aefe
Improve handling of prettier errors on format (#10156)
When no formatter for a language is specified, Zed has the default
behaviour:

1. Attempt to format the buffer with `prettier`
2. If that doesn't work, use the language server.

The problem was that if `prettier` failed to format a buffer due to
legitimate syntax errors, we simply did a fallback to the language
server, which would then format over the syntax errors.

With JavaScript/React/TypeScript projects this could lead to a situation
where

1. Syntax error was introduced
2. Prettier fails
3. Zed ignores the error
4. typescript-language-server formats the buffer despite syntax errors

This would lead to some very weird formatting issues.

What this PR does is to fix the issue by handling `prettier` errors and
results in two user facing changes:

1. When no formatter is set (or set to `auto`) and if we attempted to
start a prettier instance to format, we will now display that error and
*not* fall back to language server formatting.
2. If the formatter is explicitly set to `prettier`, we will now show
errors if we failed to spawn prettier or failed to format with it.

This means that we now might show *more* errors than previously, but I
think that's better than not showing anything to the user at all.

And, of course, it also fixes the issue of invalid syntax being
formatted by the language server even though `prettier` failed with an
error.

Release Notes:

- Improved error handling when formatting buffers with `prettier`.
Previously `prettier` errors would be logged but ignored. Now `prettier`
errors are shown in the UI, just like language server errors when
formatting. And if no formatter is specified (or set to `"auto"`) and
Zed attempts to use `prettier` for formatting, then `prettier` errors
are no longer skipped. That fixes the issue of `prettier` not formatting
invalid syntax, but its error being skipped, leading to
`typescript-language-server` or another language server formatting
invalid syntax.
2024-04-04 11:41:55 +02:00
Max Brunsfeld
256b446bdf
Refactor LSP adapter methods to compute labels in batches (#10097)
Once we enable extensions to customize the labels of completions and
symbols, this new structure will allow this to be done with a single
WASM call, instead of one WASM call per completion / symbol.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Co-authored-by: Marshall <marshall@zed.dev>
2024-04-03 09:22:56 -07:00
Thorsten Ball
eb231d0449
Add code_actions as formatter type (#10121)
This fixes #8992 and solves a problem that ESLint/Prettier/... users
have been running into:

They want to format _only_ with ESLint, which is *not* a primary
language server (so `formatter: language server` does not help) and it
is not a formatter.

What they want to use is what they get when they have configured
something like this:

```json
{
  "languages": {
    "JavaScript": {
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  }
}
```

BUT they don't want to run the formatter.

So what this PR does is to add a new formatter type: `code_actions`.

With that, users can only use code actions to format:

```json
{
  "languages": {
    "JavaScript": {
      "formatter": {
        "code_actions": {
          "source.fixAll.eslint": true
        }
      }
    }
  }
}
```

This means that when formatting (via `editor: format` or on-save) only
the code actions that are specified are being executed, no formatter.


Release Notes:

- Added a new `formatter`/`format_on_save` option: `code_actions`. When
configured, this uses language server code actions to format a buffer.
This can be used if one wants to, for example, format a buffer with
ESLint and *not* run prettier or another formatter afterwards. Example
configuration: `{"languages": {"JavaScript": {"formatter":
{"code_actions": {"source.fixAll.eslint": true}}}}}`
([#8992](https://github.com/zed-industries/zed/issues/8992)).

---------

Co-authored-by: JH Chabran <jh@chabran.fr>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-04-03 16:16:03 +02:00
Kirill Bulatov
58aec1de75
Do not push invisible local worktrees into recent documents (#10112)
Follow-up of https://github.com/zed-industries/zed/pull/9919 that
removes invisible worktrees from the list, to avoid things like

![image](https://github.com/zed-industries/zed/assets/2690773/90ce1c29-a1dd-4a03-b09a-effdba620c8f)

Release Notes:

- N/A
2024-04-03 13:47:01 +03:00
Kirill Bulatov
9aad30a559
Query code actions and hovers from all related local language servers (from remote clients) (#10111)
Supersedes https://github.com/zed-industries/zed/pull/8634
Fixes https://github.com/zed-industries/zed/issues/7947 by continuing
https://github.com/zed-industries/zed/pull/9943 with the remote part.

Now, clients are able to issue collab requests, that query all related
language servers, not only the primary one.
Such mode is enabled for GetHover and GetCodeActions LSP requests only.

Release Notes:

- Added Tailwind CSS hover popovers for Zed in multi player mode
([7947](https://github.com/zed-industries/zed/issues/7947))
2024-04-03 13:34:56 +03:00
Thorsten Ball
7dbcace839
Fix accidentally dropping shell environment variable (#10105)
Previously this code would run the changed commend, take its output,
remove the `marker` from the front and then split on `0` byte.

Problem was that `echo` adds a newline, which we did *NOT* skip. So
whatever `env` printed as the first environment variable would have a
`\n` in front of it.

Instead of setting, say, `HOME`, Zed would set `\nHOME`.

This change fixes the issue by switching to `printf '%s' marker`, which
is more portable than using `echo -n`.

This is related to https://github.com/zed-industries/zed/issues/9786 but
I'm not sure yet whether that fixes it.

Release Notes:

- Fixed Zed sometimes missing environment variables from shell in case
they were the first environment variable listed by `/usr/bin/env`.
2024-04-03 09:34:17 +02:00
Bennet Bo Fenner
1dbd520cc9
project search: Persist search history across session (#9932)
Partially implements #9717, persistence between restarts is currently
missing, but I would like to get feedback on the implementation first.

Previously the search history was not saved across different project
searches. As the `SearchHistory` is now maintained inside of the
project, it can be persisted across different project searches.

I also removed the behavior that a new query replaces the previous
search query, if it contains the text of the previous query.
I believe this was only intended to make buffer search work, therefore I
disabled this behavior but only for the project search.

Currently when you navigated through the queries the tab title changed
even if the search was not started, which doesn't make sense to me.
Current behavior:


https://github.com/zed-industries/zed/assets/53836821/1c365702-e93c-4cab-a1eb-0af3fef95476


With this PR the tab header will actually keep the search name until you
start another search again.

---

Showcase:


https://github.com/zed-industries/zed/assets/53836821/c0d6e496-915f-44bc-be16-12d7c3cda2d7


Release Notes:

- Added support for persisting project search history across a session
- Fixed tab header of project search changing when cycling through
search history, even when there is no search submitted
2024-04-02 11:13:18 +02:00
Kirill Bulatov
63e566e56e
Remove git diff base from symlinked files (#10037)
Closes https://github.com/zed-industries/zed/issues/4730

![image](https://github.com/zed-industries/zed/assets/2690773/d3c5317f-8120-45b5-b57c-c0fb5d8c066d)

To the left is a symlink, to the right — the real file.
The issue was due to the fact, that symlinks files contain the file path
to the real file, and git (properly) treats that symlink file contents
as diff base, returning in `load_index_text` (via `let content =
repo.find_blob(oid)?.content().to_owned();`) the contents of that
symlink file — the path.

The fix checks for FS metadata before fetching the git diff base, and
skips it entirely for symlinks: Zed opens the symlink file contents
instead, fully obscuring the git symlink diff hunks.

Interesting, that VSCode behaves as Zed before the fix; while the fix
makes Zed behave like Intellij* IDEs now.

Release Notes:

- Fixed git diff hunks appearing in the symlinked files
([4730](https://github.com/zed-industries/zed/issues/4730))
2024-04-01 18:22:25 +03:00
Daniel Zhu
30193647f3
Fix Recent Documents List (continues #8952) (#9919)
@SomeoneToIgnore This code should 100% work for future Zed users, but
for current Zed users, Zed's internal list of recents may not be synced
w/ macOS' Recent Documents at first. If needed this can be fixed by
calling `cx.refresh_recent_documents` on startup, but that feels a bit
unnecessary.

Release Notes:

- Fixes behavior of Recent Documents list on macOS
2024-03-29 23:17:25 +02:00
Kirill Bulatov
5d531037c4
Omit empty hovers (#9967)
Closes https://github.com/zed-industries/zed/issues/9962

Release Notes:

- N/A
2024-03-29 21:59:01 +02:00
Kirill Bulatov
c7f04691d9
Query code actions and hovers from all related local language servers (#9943)
<img width="1122" alt="Screenshot 2024-03-28 at 21 51 18"
src="https://github.com/zed-industries/zed/assets/2690773/37ef7202-f10f-462f-a2fa-044b2d806191">


Part of https://github.com/zed-industries/zed/issues/7947 and
https://github.com/zed-industries/zed/issues/9912 that adds makes Zed
query all related language servers instead of the primary one.

Collab clients are still querying the primary one only, but this is
quite hard to solve, https://github.com/zed-industries/zed/pull/8634
drafts a part of it.
The local part is useful per se, as many people use Zed & Tailwind but
do not use collab features.

Unfortunately, eslint still returns empty actions list when queried, but
querying actions for all related language servers looks reasonable and
rare enough to be dangerous.

Release Notes:

- Added Tailwind CSS hover popovers for Zed in single player mode
([7947](https://github.com/zed-industries/zed/issues/7947))
2024-03-29 12:18:38 +02:00
Thorsten Ball
7f54935324
Add git blame (#8889)
This adds a new action to the editor: `editor: toggle git blame`. When
used it turns on a sidebar containing `git blame` information for the
currently open buffer.

The git blame information is updated when the buffer changes. It handles
additions, deletions, modifications, changes to the underlying git data
(new commits, changed commits, ...), file saves. It also handles folding
and wrapping lines correctly.

When the user hovers over a commit, a tooltip displays information for
the commit that introduced the line. If the repository has a remote with
the name `origin` configured, then clicking on a blame entry opens the
permalink to the commit on the code host.

Users can right-click on a blame entry to get a context menu which
allows them to copy the SHA of the commit.

The feature also works on shared projects, e.g. when collaborating a
peer can request `git blame` data.

As of this PR, Zed now comes bundled with a `git` binary so that users
don't have to have `git` installed locally to use this feature.

### Screenshots

![screenshot-2024-03-28-13 57
43@2x](https://github.com/zed-industries/zed/assets/1185253/ee8ec55d-3b5e-4d63-a85a-852da914f5ba)

![screenshot-2024-03-28-14 01
23@2x](https://github.com/zed-industries/zed/assets/1185253/2ba8efd7-e887-4076-a87a-587a732b9e9a)
![screenshot-2024-03-28-14 01
32@2x](https://github.com/zed-industries/zed/assets/1185253/496f4a06-b189-4881-b427-2289ae6e6075)

### TODOs

- [x] Bundling `git` binary

### Release Notes

Release Notes:

- Added `editor: toggle git blame` command that toggles a sidebar with
git blame information for the current buffer.

---------

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Piotr <piotr@zed.dev>
Co-authored-by: Bennet <bennetbo@gmx.de>
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-03-28 18:32:11 +01:00
白山風露
94c51c6ac9
Windows: Enable clippy deny warnings (#9920)
~Waiting #9918~

Release Notes:

- N/A
2024-03-28 11:55:35 -04:00
Kirill Bulatov
80242584e7
Prepare editor to display multiple LSP hover responses for the same place (#9868) 2024-03-27 20:49:26 +01:00
Kirill Bulatov
ce37885f49
Use different icons for terminal tasks (#9876) 2024-03-27 20:49:10 +01:00
Conrad Irwin
140b8418c1
Stop reading deserialize_fingerprint (#9668)
Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-03-27 11:24:31 +01:00
Antonio Scandurra
fb6cff89d7
Introduce InlineCompletionProvider (#9777)
This pull request introduces a new `InlineCompletionProvider` trait,
which enables making `Editor` copilot-agnostic and lets us push all the
copilot functionality into the `copilot_ui` module. Long-term, I would
like to merge `copilot` and `copilot_ui`, but right now `project`
depends on `copilot`, which makes this impossible.

The reason for adding this new trait is so that we can experiment with
other inline completion providers and swap them at runtime using config
settings.

Please, note also that we renamed some of the existing copilot actions
to be more agnostic (see release notes below). We still kept the old
actions bound for backwards-compatibility, but we should probably remove
them at some later version.

Also, as a drive-by, we added new methods to the `Global` trait that let
you read or mutate a global directly, e.g.:

```rs
MyGlobal::update(cx, |global, cx| {
});
```

Release Notes:

- Renamed the `copilot::Suggest` action to
`editor::ShowInlineCompletion`
- Renamed the `copilot::NextSuggestion` action to
`editor::NextInlineCompletion`
- Renamed the `copilot::PreviousSuggestion` action to
`editor::PreviousInlineCompletion`
- Renamed the `editor::AcceptPartialCopilotSuggestion` action to
`editor::AcceptPartialInlineCompletion`

---------

Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Kyle <kylek@zed.dev>
Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
2024-03-26 13:28:06 +01:00
Kirill Bulatov
e3894a4e1e
Document main workspace structs (#9772) 2024-03-25 16:09:51 +01:00
Mayfield
4785520d99
Support newline and tab literals in regex search-and-replace operations (#9609)
Closes #7645

Release Notes:

- Added support for inserting newlines (`\n`) and tabs (`\t`) in editor
Regex search replacements
([#7645](https://github.com/zed-industries/zed/issues/7645)).
2024-03-25 12:21:04 +01:00
Max Brunsfeld
6ebe599c98
Fix issues with extension API that come up when moving Svelte into an extension (#9611)
We're doing it. Svelte support is moving into an extension. This PR
fixes some issues that came up along the way.

Notes

* extensions need to be able to retrieve the path the `node` binary
installed by Zed
* previously we were silently swallowing any errors that occurred while
loading a grammar
* npm commands ran by extensions weren't run in the right directory
* Tree-sitter's WASM stdlib didn't support a C function (`strncmp`)
needed by the Svelte parser's external scanner
* the way that LSP installation status was reported was unnecessarily
complex

Release Notes:

- Removed built-in support for the Svelte and Gleam languages, because
full support for those languages is now available via extensions. These
extensions will be suggested for download when you open a `.svelte` or
`.gleam` file.

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-22 17:29:06 -07: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
945d8c2112
Revert "Revert "chore: Bump Rust version to 1.77 (#9631)"" (#9672)
Reverts zed-industries/zed#9658, as the Docker image is now available.

Release notes:

- N/A
2024-03-22 11:17:16 +01:00
Ezekiel Warren
0f15fd37d6
windows: User installed language server support (#9606)
Release Notes:

- N/A
2024-03-21 15:25:26 -07:00
Conrad Irwin
eaa803298e
Fix error handling in buffer open (#9667)
Co-Authored-By: Max <max@zed.dev>
Co-Authored-By: Marshall <marshall@zed.dev>

Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
2024-03-21 15:57:20 -06:00
Conrad Irwin
caed275fbf Revert "language: Remove buffer fingerprinting (#9007)"
This reverts commit 6f2f61c9b1.
2024-03-21 14:10:18 -06:00
Stanislav Alekseev
3b7cd9cf1e
Remove incorrect venv base directory used (#9661)
Follow-up of https://github.com/zed-industries/zed/pull/8444

Release Notes:

- N/A
2024-03-21 21:34:14 +02:00
Marshall Bowers
d557f8e36c
Revert "chore: Bump Rust version to 1.77 (#9631)" (#9658)
This reverts commit 6184278faf.

We can't upgrade to Rust 1.77 until there are Rust 1.77 Docker images
available
(https://github.com/docker-library/official-images/pull/16457).


Release Notes:

- N/A
2024-03-21 14:07:22 -04:00
Stanislav Alekseev
85fdcef564
Do not enable venv in terminal for bash-like oneshot task invocations (#8444)
Release Notes:
- Work around #8334 by only activating venv in the terminal not in tasks
(see #8440 for a proper solution)
- To use venv modify your tasks in the following way:
```json
{
  "label": "Python main.py",
  "command": "sh",
  "args": ["-c", "source .venv/bin/activate && python3 main.py"]
}
```

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2024-03-21 19:40:33 +02:00
Piotr Osiewicz
6f2f61c9b1
language: Remove buffer fingerprinting (#9007)
Followup to #9005 that actually removes buffer fingerprinting.

Release Notes:

- N/A
2024-03-21 17:03:26 +01:00
Piotr Osiewicz
e20508f66c
lsp: Add partial support for insert/replace completions (#9634)
Most notably, this should do away with completions overriding the whole
word around completion trigger text. Fixes: #4816



Release Notes:

- Fixed code completions overriding text around the cursor.
2024-03-21 16:19:21 +01:00
Piotr Osiewicz
6184278faf
chore: Bump Rust version to 1.77 (#9631)
Release Notes:

- N/A
2024-03-21 15:42:59 +01:00
Max Brunsfeld
d699b8e104
Allow extensions to define more of the methods in the LspAdapter trait (#9554)
Our goal is to extract Svelte support into an extension, since we've
seen problems with the Tree-sitter Svelte parser crashing due to bugs in
the external scanner. In order to do this, we need a couple more
capabilities in LSP extensions:

* [x] `initialization_options` - programmatically controlling the JSON
initialization params sent to the language server
* [x] `prettier_plugins` - statically specifying a list of prettier
plugins that apply for a given language.
* [x] `npm_install_package`

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-03-20 12:47:04 -07:00
Anthony Eid
88857f8149
VS Code -> Zed tasks converter (#9538)
We can convert shell, npm and gulp tasks to a Zed format. Additionally, we convert a subset of task variables that VsCode supports.

Release notes:

- Zed can now load tasks in Visual Studio Code task format

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-03-20 16:37:26 +01:00
Conrad Irwin
d6b7f14b51
suggested extensions (#9526)
Follow-up from #9138

Release Notes:

- Adds suggested extensions for some filetypes
([#7096](https://github.com/zed-industries/zed/issues/7096)).

---------

Co-authored-by: Felix Zeller <felixazeller@gmail.com>
2024-03-19 10:06:01 -06:00
Conrad Irwin
f738bfd703
Don't panic on missing mtime (#9513)
This is expected as of zed 0.128 when a new unsaved file is created

Release Notes:

- Fixed a panic when collaborating with newer zed versions
2024-03-18 14:19:33 -06:00
Thorsten Ball
a69eddc081
Limit project search to avoid unresponsive app (#9404)
This fixes #[#9135](https://github.com/zed-industries/zed/issues/9135)
by introducing file/results limit to project search.

It does this by changing how project search works in multiple ways.

User-facing changes:

- Number files that are being searched is now limited to 5000
- Number of search results in all files is now limited to 10000
- If a limit is reached, search is stopped and a message is displayed
  to the user

Under the hood, we also reworked `Project::search_local`:

- Code has been refactored so that the concurrency-logic is easier to
  distinguish from the search logic.
- We now limit the number of concurrent `open_buffer` operations, since
  that is being done on the main thread and can lead to beachballs when
  finding a lot of results.

Note for reviewer:

@SomeoneToIgnore since you know this code, can you take a look at this?
The changes might look bigger than they are in certain places because I
only extracted code into functions, but the middle part — the sorting of
file paths — has changed in order to avoid too many tasks opening
buffers at the same time and making app unresponsive.

What's also curious is that I think there was a bug in that we searched
ignored entries _twice_: once in `search_snapshots` and then later in
the dedicated `search_ignored_entry` function. I changed the `entries()`
call in `search_snapshots` so that it's always `false`, but that caused
tests to fail (see `test_search_in_gitignored_dirs`). @bennetbo and I
think that there's some state in the Project that made the tests pass
before, because the last of the 3 assertions in that test only passes
when the other two queries run. So we changed the test to be more
stateless and included the possible fix in `search_snapshots`.

Release Notes:

- Fixed project-wide search leading to unresponsive application when
searching in ignored files, by limiting the number of files that are
searched (to 5000) and the number of overall search results to 10000.
Additional performance improvements have also been made in order to
offload more work onto a background thread.
([#9135](https://github.com/zed-industries/zed/issues/9135)).

---------

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
Co-authored-by: Bennet <bennetbo@gmx.de>
2024-03-18 10:49:27 +01:00
Kyle Kelley
72d36d0213
Foundations for Open All the Things (#9353)
This is the beginning of setting up a flexible way to open items beyond
the text buffer -- think notebooks, images, GeoJSON, etc. The primary
requirement to allow opening an arbitrary file is `try_open` on the
`project::Item` trait. Now we can make new `Item`s for other types with
their own ways to render.

Under the hood, `register_project_item` uses this new opening scheme. It
supports a dynamic array of opener functions, that will handle specific
item types. By default, a `Buffer` should be able to be able to open any
file that another opener did not.

A key detail here is that the order of registration matters. The last
item has primacy. Here's an example:

```rust
workspace::register_project_item::<Editor>(cx);
workspace::register_project_item::<Notebook>(cx);
workspace::register_project_item::<ImageViewer>(cx);
```

When a project item (file) is attempted to be opened, it's first tried
with the `ImageViewer`, followed by the `Notebook`, then the `Editor`.

The tests are set up in a way that should make it _hopefully_ easy to
learn how to write a new opener. First to go after should probably be
image files.

Release Notes:

N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2024-03-14 18:01:40 -07:00
Marshall Bowers
7f3f296e81
Enable clippy::await_holding_lock (#9362)
This PR enables the
[`clippy::await_holding_lock`](https://rust-lang.github.io/rust-clippy/master/index.html#/await_holding_lock)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-14 15:24:19 -04:00