Commit Graph

1609 Commits

Author SHA1 Message Date
Piotr Osiewicz
bac6e2fee7
tasks: Add experimental support for user-defined task variables (#13699)
Context:
@bennetbo spotted a regression in handling of `cargo run` task in zed
repo following a merge of #13658. We've started invoking `cargo run`
from the folder of an active file whereas previously we did it from the
workspace root. We brainstormed few solutions that involved adding a
separate task that gets invoked at a workspace level, but I realized
that a cleaner solution may be to finally add user-configured task
variables. This way, we can choose which crate to run by default at a
workspace level.

This has been originally brought up in the context of javascript tasks
in
https://github.com/zed-industries/zed/pull/12118#issuecomment-2129232114

Note that this is intended for internal use only for the time being.
/cc @RemcoSmitsDev we should be unblocked on having runner-dependant
tasks now.

Release notes:

- N/A
2024-07-01 15:59:19 +02:00
Conrad Irwin
cd81dad2fa
fix panics (#13554)
Release Notes:

- Fixed a panic when editing HTML near the end of a file
- Fixed a panic when editing settings.json from inside the .zed
directory
2024-06-26 14:32:16 -06:00
Max Brunsfeld
6fba1e46a8
Remove never-used client parameter from message handler functions (#13406)
Every single client-side RPC message handler function took an unused
`Arc<Client>` parameter. This removes that.

Release Notes:

- N/A
2024-06-22 16:07:36 -07:00
Max Brunsfeld
89d2ace713
Make LSP task cancellation discoverable (#13226)
Release Notes:

- Added the ability to cancel a cargo check by clicking on the status
bar item.
2024-06-18 12:44:35 -07:00
Marshall Bowers
81475ac4cd
paths: Replace lazy_static! with OnceLock (#13213)
This PR replaces the `lazy_static!` usages in the `paths` crate with
`OnceLock` from the standard library.

This allows us to drop the `lazy_static` dependency from this crate.

The paths are now exposed as accessor functions that reference a private
static value.

Release Notes:

- N/A
2024-06-18 12:22:37 -04:00
Piotr Osiewicz
5dc26c261d
util: Use GlobSet in PathMatcher (#13197)
Previously we were using a single globset::Glob in PathMatcher; higher
up the stack, we were then resorting to using a list of PathMatchers.
globset crate exposes a GlobSet type that's better suited for this use
case. In my benchmarks, using a single PathMatcher with GlobSet instead
of a Vec of PathMatchers with Globs is about 3 times faster with the
default 'file_scan_exclusions' values. This slightly improves our
project load time for projects with large # of files, as showcased in
the following videos of loading a project with 100k source files. This
project is *not* a git repository, so it should measure raw overhead on
our side.

Current nightly: 51404d4ea0


https://github.com/zed-industries/zed/assets/24362066/e0aa9f8c-aae6-4348-8d42-d20bd41fcd76

versus this PR:


https://github.com/zed-industries/zed/assets/24362066/408dcab1-cee2-4c9e-a541-a31d14772dd7



Release Notes:

- Improved performance in large worktrees
2024-06-18 16:12:24 +02:00
Piotr Osiewicz
3a26a4809d
lsp: Revert URL type change (#13193)
This reverts URI changes made in
https://github.com/zed-industries/zed/pull/12928 while keeping the perf
goodies in tact. We should keep an eye out for
https://github.com/gluon-lang/lsp-types/issues/284
Fixes: https://github.com/zed-industries/zed/issues/13135
Fixes: https://github.com/zed-industries/zed/issues/13131
Release Notes:

- N/A
2024-06-18 12:39:56 +02:00
Max Brunsfeld
7003b0f211
Allow canceling in-progress language server work (e.g. cargo check) (#13173)
Release Notes:

- Added a more detailed message in place of the generic `checking...`
messages when Rust-analyzer is running.
- Added a rate limit for language server status messages, to reduce
noisiness of those updates.
- Added a `cancel language server work` action which will cancel
long-running language server tasks.

---------

Co-authored-by: Richard <richard@zed.dev>
2024-06-17 17:58:47 -07:00
Marshall Bowers
258a8a37d8
Extract paths out of util (#13182)
This PR extracts the definition of the various Zed paths out of `util`
and into a new `paths` crate.

`util` is for generic utils, while these paths are Zed-specific. For
instance, `gpui` depends on `util`, and it shouldn't have knowledge of
these paths, since they are only used by Zed.

Release Notes:

- N/A
2024-06-17 19:27:42 -04:00
Joseph T. Lyons
ca035dbdd8
Move project event logic to telemetry.rs (#13166)
I previously put this logic directly into `project.rs`, but it doesn't
feel good to pollute that code with telemetry logic, so I've moved it
over to `telemetry.rs`.

Release Notes:

- N/A
2024-06-17 15:52:59 -04:00
Joseph T. Lyons
ff2347dff5
Add events for identifying node projects (#13078)
Release Notes:

- N/A
2024-06-15 00:34:04 -04:00
Max Brunsfeld
af45db6d1e
Fix FS-related issues that were causing a test failure on linux (#13072)
This fixes `project_tests::rescan_and_remote_updates` .

That test was actually correctly failing, revealing two bugs on Linux.

Release Notes:

- Fixed an issue where file renames were not detected on Linux.
- Fixed performance problems caused by excessive file system events on
Linux.

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-06-14 16:03:34 -07:00
Marshall Bowers
6ca09bd4ba
project: Disable project_tests::test_rescan_and_remote_updates on Linux (#13062)
This PR disables the
`project::project_tests::test_rescan_and_remote_updates` test on Linux,
as we've been seeing it fail quite consistently in CI.

We can re-enable it once we've had a chance to investigate and fix.

Release Notes:

- N/A
2024-06-14 14:20:52 -04:00
Conrad Irwin
993109aee1
Fix panic in worktree scanning (#13057)
Release Notes:

- Fixed a panic when worktree paths are incorrectly relative.
2024-06-14 10:23:20 -07:00
Kirill Bulatov
a8481099ca
Prefer the same order of entries inside outline and project panels, project search multi buffer (#13044)
Release Notes:

- N/A
2024-06-14 18:33:36 +03:00
Bennet Bo Fenner
0d8e6e6b12
assistant: Add diagnostics slash command (#12998)
This adds a `diagnostics` command to the assistant which allows to
inject compile errors/warnings into the context.

Release Notes:

- N/A
2024-06-14 17:14:50 +02:00
Piotr Osiewicz
dcb8dc16ca
editor: Update insert_text_format based on resolved completion (#13041)
Fixes #12920

VTSLS does not mark snippet completions as such in the initial
completion response - not until we resolve them; however, we do not
touch initial contents of completion during resolution, which led to us
not treating a snippet as such.

Release Notes:

- Fixed snippet completions sometimes being treated as plain text
completions when using VTSLS
2024-06-14 13:31:02 +02:00
Mikayla Maki
10d3ad4e33
Enable linux tests (#12493)
Note:
- We have disabled all tests that rely on Postgres in the Linux CI. We
only really need to test these once, and as macOS is our team's primary
platform, we'll only enable them on macOS for local reproduction.
- We have disabled all tests that rely on the font metrics. We
standardized on Zed Mono in many fonts, but our CoreText Text System and
Cosmic Text System proved to be very different in effect. We should
revisit if we decide to standardize our text system across platforms
(e.g. using Harfbuzz everywhere)
- Extended the condition timeout significantly. Our CI machines are slow
enough that this is causing spurious errors in random tests.

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-06-13 16:38:53 -07:00
Piotr Osiewicz
0a13b9ee01
lsp: Provide completion reason in the request (#12893)
This should help LS make a better call about the completions it should
return back to the caller. For example, it speeds up import completions
for typescript.
Before: 


https://github.com/zed-industries/zed/assets/24362066/b38fd565-f9ff-4db7-a87f-c3b31a9fdc96

after: 


https://github.com/zed-industries/zed/assets/24362066/d4fbc9ae-9aab-4543-b9f6-16acf1619576


This should be merged after 06.12 Preview to give it some time on
Nightly.

Release Notes:

- N/A
2024-06-13 14:38:34 +02:00
Piotr Osiewicz
7798f64d1b
chore: Bump lsp-types to 0.97.0 (#12928)
This also includes https://github.com/gluon-lang/lsp-types/pull/287,
which should significantly reduce the time it takes for us to
deserialize completion lists.


Release Notes:
- N/A
2024-06-13 13:48:12 +02:00
Mikayla Maki
80c14c9198
Pull app / OS info out of GPUI, add Linux information, make fallible window initialization (#12869)
TODO:
- [x] Finish GPUI changes on other operating systems 

This is a largely internal change to how we report data to our
diagnostics and telemetry. This PR also includes an update to our blade
backend which allows us to report errors in a more useful way when
failing to initialize blade.


Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-06-11 11:43:12 -07:00
Piotr Osiewicz
b6ea393d14
lsp: Add support for linked editing range edits (HTML tag autorenaming) (#12769)
This PR adds support for [linked editing of
ranges](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_linkedEditingRange),
which in short means that editing one part of a file can now change
related parts in that same file. Think of automatically renaming
HTML/TSX closing tags when the opening one is changed.
TODO:
- [x] proto changes
- [x] Allow disabling linked editing ranges on a per language basis.

Fixes #4535 

Release Notes:
- Added support for linked editing ranges LSP request. Editing opening
tags in HTML/TSX files (with vtsls) performs the same edit on the
closing tag as well (and vice versa). It can be turned off on a language-by-language basis with the following setting:
```
  "languages": {
    "HTML": {
      "linked_edits": true
    },
  }
```

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-06-11 15:52:38 +02:00
Conrad Irwin
4e98c23463
Reconnect button for remote projects (#12669)
Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
2024-06-10 18:09:47 -06:00
Max Brunsfeld
e174f16d50
Refactor: Make it possible to share a remote worktree (#12775)
This PR is an internal refactor in preparation for remote editing. It
restructures the public interface of `Worktree`, reducing the number of
call sites that assume that a worktree is local or remote.

* The Project no longer calls `worktree.as_local_mut().unwrap()` in code
paths related to basic file operations
* Fewer code paths in the app rely on the worktree's `LocalSnapshot`
* Worktree-related RPC message handling is more fully encapsulated by
the `Worktree` type.

to do:
* [x] file manipulation operations
* [x] sending worktree updates when sharing

for later
* opening buffers
* updating open buffers upon worktree changes

Release Notes:

- N/A
2024-06-07 12:53:01 -07:00
Joseph T. Lyons
3eac83eece
Add event for yarn project identification (#12785)
Report a `open yarn project` `app_event` for each worktree where
`yarn.lock` is found and only report it once per session.

Release Notes:

- N/A
2024-06-07 14:30:38 -04:00
Stanislav Alekseev
07dbd2bce8
Use rust-analyzer from path if possible (#12418)
Release Notes:

- Added support for looking up the `rust-analyzer` binary in `$PATH`. This allows using such tools as `asdf` and nix to configure per-folder rust installations. To enable this behavior, use the `path_lookup` key when configuring the `rust-analyzer` `binary`: `{"lsp": {"rust-analyzer": {"binary": {"path_lookup": true }}}}`.
2024-06-07 06:56:38 +02:00
Max Brunsfeld
48581167b7
Remove dependencies from the Worktree crate and make it more focused (#12747)
The `worktree` crate mainly provides an in-memory model of a directory
and its git repositories. But because it was originally extracted from
the Project crate, it also contained lingering bits of code that were
outside of that area:
* it had a little bit of logic related to buffers (though most buffer
management lives in `project`)
* it had a *little* bit of logic for storing diagnostics (though the
vast majority of LSP and diagnostic logic lives in `project`)
* it had a little bit of logic for sending RPC message (though the
*receiving* logic for those RPC messages lived in `project`)

In this PR, I've moved those concerns entirely to the project crate
(where they were already dealt with for the most part), so that the
worktree crate can be more focused on its main job, and have fewer
dependencies.

Worktree no longer depends on `client` or `lsp`. It still depends on
`language`, but only because of `impl language::File for
worktree::File`.

Release Notes:

- N/A
2024-06-06 11:16:58 -07:00
Piotr Osiewicz
377e24b798
chore: Fix clippy for upcoming 1.79 Rust release (#12727)
1.79 is due for release in a week.
Release Notes:

- N/A
2024-06-06 12:46:53 +02:00
Conrad Irwin
c7d56302d2
Always open the project panel for dev server projects (#12654)
Release Notes:

- N/A
2024-06-04 16:07:12 -06:00
Conrad Irwin
1c617474fe
Allow restarting remote language servers (#12652)
Release Notes:

- Added the ability to restart the remote language servers when
collaborating
2024-06-04 14:09:01 -06:00
Kirill Bulatov
47122a3115
Fix excluded file creation (#12620)
Fixes https://github.com/zed-industries/zed/issues/10890

* removes `unwrap()` that caused panics for text elements with no text,
remaining after edit state is cleared but project entries are not
updated, having the fake, "new entry"
* improves discoverability of the FS errors during file/directory
creation: now those are shown as workspace notifications
* stops printing anyhow backtraces in workspace notifications, printing
the more readable chain of contexts instead
* better indicates when new entries are created as excluded ones


Release Notes:

- Improve excluded entry creation workflow in the project panel
([10890](https://github.com/zed-industries/zed/issues/10890))
2024-06-04 10:31:43 +03:00
Bennet Bo Fenner
d0fa012bf8
Support formatting unsaved buffers with external formatter (#12597)
Closes #4529


https://github.com/zed-industries/zed/assets/53836821/b84efd5e-89da-4ff7-9a29-2b2f7285d427

Release Notes:

- Added ability to format unsaved buffers with external formatters
([#4529](https://github.com/zed-industries/zed/issues/4529))
2024-06-03 16:32:16 +02:00
Jason Lee
ae55d35f19
windows: Fix project prepare_ssh_shell to support setting PATH on Windows (#12370)
Release Notes:

- N/A

Update to use `std::env::join_paths` to prepare `PATH` env.

Ref
https://github.com/zed-industries/zed/pull/12087#issuecomment-2122852384
@mrnugget

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-06-03 11:57:50 +02:00
Max Brunsfeld
8f942bf647
Use repository mutex more sparingly. Don't hold it while running git status. (#12489)
Previously, each git `Repository` object was held inside of a mutex.
This was needed because libgit2's Repository object is (as one would
expect) not thread safe. But now, the two longest-running git operations
that Zed performs, (`status` and `blame`) do not use libgit2 - they
invoke the `git` executable. For these operations, it's not necessary to
hold a lock on the repository.

In this PR, I've moved our mutex usage so that it only wraps the libgit2
calls, not our `git` subprocess spawns. The main user-facing impact of
this is that the UI is much more responsive when initially opening a
project with a very large git repository (e.g. `chromium`, `webkit`,
`linux`).

Release Notes:

- Improved Zed's responsiveness when initially opening a project
containing a very large git repository.
2024-05-30 09:37:11 -07:00
Kirill Bulatov
0f927fa6fb
One less unwrap (#12448)
Fixes
https://zed-industries.slack.com/archives/C04S6T1T7TQ/p1717011343884699

Release Notes:

- N/A
2024-05-29 23:44:56 +03:00
Antonio Scandurra
66affa969a
Show recently-opened files when autocompleting /file without arguments (#12434)
<img width="1588" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/ea63b046-64d6-419e-8135-4863748b58fa">


Release Notes:

- N/A
2024-05-29 17:46:18 +02:00
Jason Lee
3c6c850390
task: Add re-run task button to terminal title (#12379)
Release Notes:

- Added re-run task button to terminal title.

Close #12277

## Demo


https://github.com/zed-industries/zed/assets/5518/4cd05fa5-4255-412b-8583-68e22f86561e

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
2024-05-29 11:40:43 +02:00
Antonio Scandurra
7e3ab9acc9
Rework context insertion UX (#12360)
- Confirming a completion now runs the command immediately
- Hitting `enter` on a line with a command now runs it
- The output of commands gets folded away and replaced with a custom
placeholder
- Eliminated ambient context

<img width="1588" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/b1927a45-52d6-4634-acc9-2ee539c1d89a">

Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2024-05-27 17:44:54 -06:00
Max Brunsfeld
f7a86967fd
Avoid holding worktree lock for a long time while updating large repos' git status (#12266)
Fixes https://github.com/zed-industries/zed/issues/9575
Fixes https://github.com/zed-industries/zed/issues/4294

### Problem

When a large git repository's `.git` folder changes (due to a `git
commit`, `git reset` etc), Zed needs to recompute the git status for
every file in that git repository. Part of computing the git status is
the *unstaged* part - the comparison between the content of the file and
the version in the git index. In a large git repository like `chromium`
or `linux`, this is inherently pretty slow.

Previously, we performed this git status all at once, and held a lock on
our `BackgroundScanner`'s state for the entire time. On my laptop, in
the `linux` repo, this would often take around 13 seconds.

When opening a file, Zed always refreshes the metadata for that file in
its in-memory snapshot of worktree. This is normally very fast, but if
another task is holding a lock on the `BackgroundScanner`, it blocks.

###  Solution

I've restructured how Zed handles Git statuses, so that when a git
repository is updated, we recompute files' git statuses in fixed-sized
batches. In between these batches, the `BackgroundScanner` is free to
perform other work, so that file operations coming from the main thread
will still be responsive.

Release Notes:

- Fixed a bug that caused long delays in opening files right after
performing a commit in very large git repositories.
2024-05-24 17:41:35 -07:00
Marshall Bowers
82f5f36422
Allow defining slash commands in extensions (#12255)
This PR adds initial support for defining slash commands for the
Assistant from extensions.

Slash commands are defined in an extension's `extension.toml`:

```toml
[slash_commands.gleam-project]
description = "Returns information about the current Gleam project."
requires_argument = false
```

and then executed via the `run_slash_command` method on the `Extension`
trait:

```rs
impl Extension for GleamExtension {
    // ...

    fn run_slash_command(
        &self,
        command: SlashCommand,
        _argument: Option<String>,
        worktree: &zed::Worktree,
    ) -> Result<Option<String>, String> {
        match command.name.as_str() {
            "gleam-project" => Ok(Some("Yayyy".to_string())),
            command => Err(format!("unknown slash command: \"{command}\"")),
        }
    }
}
```

Release Notes:

- N/A
2024-05-24 15:44:32 -04:00
Kirill Bulatov
055a13a9b6
Allow clients to run Zed tasks on remote projects (#12199)
Release Notes:

- Enabled Zed tasks on remote projects with ssh connection string
specified

---------

Co-authored-by: Conrad Irwin <conrad@zed.dev>
2024-05-24 22:26:57 +03:00
Piotr Osiewicz
0eff1eae76
task: Add ZED_DIRNAME and ZED_RELATIVE_FILE task variables (#12245)
Release Notes:

- Added ZED_RELATIVE_FILE (path to current file relative to worktree
root) and ZED_DIRNAME (path to the directory containing current file)
task variables.
2024-05-24 16:04:24 +02:00
Elliot Thomas
b9697fb487
Enable manual worktree organization (#11504)
Release Notes:

- Preserve order of worktrees in project
([#10883](https://github.com/zed-industries/zed/issues/10883)).
- Enable drag-and-drop reordering for project worktrees

Note: worktree order is not synced during collaboration but guests can
reorder their own project panels.

![Reordering
worktrees](https://github.com/zed-industries/zed/assets/1347854/1c63d83c-5d4e-4b55-b840-bfbf32521b2a)

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2024-05-24 12:15:48 +03:00
Remco Smits
1e5389a2be
rust: Add runnable icon for #[cfg(test)] mod tests (#12017)
This allows you to run all the tests inside the `mod tests` block. 
Fixes #11967.

<img width="366" alt="Screenshot 2024-05-18 at 16 07 32"
src="https://github.com/zed-industries/zed/assets/62463826/01fc378c-1546-421d-8250-fe0227c1e5a0">

<img width="874" alt="Screenshot 2024-05-18 at 16 37 21"
src="https://github.com/zed-industries/zed/assets/62463826/4a880b91-df84-4917-a16e-5d5fe20e22ac">

Release Notes:

- Added runnable icon for Rust `#[cfg(test)] mod tests` blocks
([#11967](https://github.com/zed-industries/zed/issues/11967)).
2024-05-24 11:02:23 +02:00
Piotr Osiewicz
58796a8480
tasks: Expose captured variables to ContextProvider (#12134)
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
2024-05-22 19:45:43 +02:00
Kirill Bulatov
c4e87444e7
Tidy up the code (#12116)
Small follow-ups for https://github.com/zed-industries/zed/pull/12063
and https://github.com/zed-industries/zed/pull/12103

Release Notes:

- N/A
2024-05-22 14:36:15 +03:00
Conrad Irwin
e5b9e2044e
Allow ssh connection for setting up zed (#12063)
Co-Authored-By: Mikayla <mikayla@zed.dev>



Release Notes:

- Magic `ssh` login feature for remote development

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Nate Butler <iamnbutler@gmail.com>
2024-05-21 22:39:16 -06:00
Thorsten Ball
c290d924f1
Allow formatting of unsaved buffers with prettier (#12095)
This fixes #4529 by allowing unsaved buffers to be formatted with
prettier.

Steps to do that:

1. Create a new buffer
2. Set language for the buffer (e.g.: `language selector: toggle` and
JSON)
3. In settings, set prettier parser for language (can't be inferred,
since we don't have filename) and allow formatting with prettier:

   ```json
   {
     "languages": {
       "JSON": {
         "prettier": {
           "allowed": true,
           "parser": "json"
         }
       }
     }
   }
   ```

4. Use `editor: format`

Release Notes:

- Added ability to format unsaved buffers with Prettier. Requirement is
to set a Prettier parser in the user settings. Example for JSON: `{
"languages": { "JSON": { "prettier": { "allowed": true, "parser": "json"
} } } }` ([#4529](https://github.com/zed-industries/zed/issues/4529)).

Demo:


https://github.com/zed-industries/zed/assets/1185253/d24e490b-2e2c-4a5d-95a8-fc8675523780
2024-05-22 06:19:32 +02:00
Thorsten Ball
b89f360199
lsp: Handle client/unregisterCapability to fix gopls (#12086)
This fixes #10224 by handling `client/unregisterCapability` requests
that have a `workspace/didChangeWatchedFiles` method.

While debugging the issue, I found out that `gopls` seems to block
indefinitely when there's no reply to the `client/unregisterCapability`
request. Even an empty response would fix the issue.

Seems like gopls 15.x and later seem to handle nested subfolders well,
but do not handle unanswered requests.

Instead of replying with an empty response, I decided to change how we
handle file watching and keep a list of all registered paths so that we
can then unregister paths and recreate the glob patterns.

Release Notes:

- Fixed `gopls` not working correctly when the `go.mod` file was in a
subfolder and not the root folder of the project opened in Zed.
([#10224](https://github.com/zed-industries/zed/issues/10224)).
2024-05-21 19:17:29 +02:00
Piotr Osiewicz
0b8c1680fb
html: Add support for autoclosing of tags (#11761)
Fixes #5267 
TODO:
- [x] Publish our fork of vscode-langservers-extracted on GH and wire
that through as a language server of choice for HTML extension.
- [x] Figure out how to prevent edits made by remote participants from
moving the cursor of a host.

Release Notes:

- Added support for autoclosing of HTML tags in local projects.
2024-05-20 17:00:27 +02:00