Commit Graph

123 Commits

Author SHA1 Message Date
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
白山風露
c0f8581b29
Windows: implement symlink (#9508)
Since Windows has a distinction between symlinks for directories and
symlinks for files, the implementation is adapted to this distinction.

Release Notes:

- N/A
2024-03-18 14:27:39 -07:00
张小白
cbf960e979
Windows: make fs to use workspace windows crate (#9350)
Release Notes:

- N/A
2024-03-14 10:43:06 -07:00
Piotr Osiewicz
5f02ef701d
fs: Remove unused import (#9344)
Followup to #9341 as I've noticed a CI failure on bundling step of my
other PR
(https://github.com/zed-industries/zed/actions/runs/8283419386/job/22666698264)
Release Notes:

- N/A
2024-03-14 16:55:32 +01:00
Thorsten Ball
7629c16162
Always read files to string on a background thread (#9341)
We noticed that when you open a lot of files (i.e. project-wide search
with multi-buffer) that the main thread can become unresponsive, because
while we are async, we still load these files on the main thread.

What this change does is it uses `smol::unblock` to load files on a
different thread.

Release Notes:

- Improved responsiveness when loading files into memory.

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Kirill <kirill@zed.dev>
2024-03-14 16:17:12 +01:00
Conrad Irwin
646f69583a
Allow opening non-extant files (#9256)
Fixes #7400



Release Notes:

- Improved the `zed` command to not create files until you save them in
the editor ([#7400](https://github.com/zed-industries/zed/issues/7400)).
2024-03-12 22:30:04 -06:00
Mikayla Maki
ca696fd5f6
Add rs-notify implementation of fs::watch (#9040)
This PR simplifies the Zed file system abstraction and implements
`Fs::watch` for linux and windows.

TODO:
- [x] Figure out why this fails to initialize the file watchers when we
have to initialize the config directory paths, but succeeds on
subsequent runs.
- [x] Fix macOS dependencies on old fsevents::Event crate

Release Notes:

- N/A
2024-03-08 22:18:44 -08:00
Piotr Osiewicz
7b73e2824b
fs: allocate backing storage once in Fs::load (#9020)
`futures_lite::AsyncReadExt::read_to_string` (that we use in
`RealFs::load`) explicitly does not allocate memory for String contents
up front, which leads to excessive reallocations. That reallocation time
is a significant contributor to the time we spend loading files (esp
large ones). For example, out of ~1s that it takes to open up a 650Mb
ASCII buffer on my machine (after changes related to fingerprinting from
#9007), 350ms is spent in `RealFs::load`.
This change slashes that figure to ~110ms, which is still *a lot*. About
60ms out of 110ms remaining is spent zeroing memory. Sadly,
`AsyncReadExt` API forces us to zero a buffer we're reading into
(whether it's via read_to_string or read_exact), but at the very least
this commit alleviates unnecessary reallocations.

We could probably use something like
[simdutf8](https://docs.rs/simdutf8/latest/simdutf8/) to speed up UTF8
validation in this method as well, though that takes only about ~18ms
out of 110ms, so while it is significant, I've left that out for now.
Memory zeroing is a bigger problem at this point.

Before:

![image](https://github.com/zed-industries/zed/assets/24362066/5e53c004-8a02-47db-bc75-04cb4113a6bc)

After:

![image](https://github.com/zed-industries/zed/assets/24362066/00099032-d647-4683-b290-eaeb969cac4a)

/cc @as-cii 

Release Notes:

- Improved performance when loading large files.
2024-03-08 14:40:26 +01:00
Max Brunsfeld
675ae24964
Add a command for building and installing a locally-developed Zed extension (#8781)
This PR adds an `zed: Install Local Extension` action, which lets you
select a path to a folder containing a Zed extension, and install that .
When you select a directory, the extension will be compiled (both the
Tree-sitter grammars and the Rust code for the extension itself) and
installed as a Zed extension, using a symlink.

### Details

A few dependencies are needed to build an extension:
* The Rust `wasm32-wasi` target. This is automatically installed if
needed via `rustup`.
* A wasi-preview1 adapter WASM module, for building WASM components with
Rust. This is automatically downloaded if needed from a `wasmtime`
GitHub release
* For building Tree-sitter parsers, a distribution of `wasi-sdk`. This
is automatically downloaded if needed from a `wasi-sdk` GitHub release.

The downloaded artifacts are cached in a support directory called
`Zed/extensions/build`.

### Tasks

UX

* [x] Show local extensions in the Extensions view
* [x] Provide a button for recompiling a linked extension
* [x] Make this action discoverable by adding a button for it on the
Extensions view
* [ ] Surface errors (don't just write them to the Zed log)

Packaging

* [ ] Create a separate executable that performs the extension
compilation. We'll switch the packaging system in our
[extensions](https://github.com/zed-industries/extensions) repo to use
this binary, so that there is one canonical definition of how to
build/package an extensions.

### Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-03-06 15:35:22 -08:00
Marshall Bowers
22fe03913c
Move Clippy configuration to the workspace level (#8891)
This PR moves the Clippy configuration up to the workspace level.

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

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

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

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

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

Release Notes:

- N/A
2024-03-05 12:01:17 -05:00
Marshall Bowers
26fdd149e1
Fix Clippy warnings in fs (#8696)
This PR fixes various Clippy warnings in the `fs` crate.

Release Notes:

- N/A
2024-03-01 23:22:22 -05:00
Max Brunsfeld
268fa1cbaf
Add initial support for defining language server adapters in WebAssembly-based extensions (#8645)
This PR adds **internal** ability to run arbitrary language servers via
WebAssembly extensions. The functionality isn't exposed yet - we're just
landing this in this early state because there have been a lot of
changes to the `LspAdapter` trait, and other language server logic.

## Next steps

* Currently, wasm extensions can only define how to *install* and run a
language server, they can't yet implement the other LSP adapter methods,
such as formatting completion labels and workspace symbols.
* We don't have an automatic way to install or develop these types of
extensions
* We don't have a way to package these types of extensions in our
extensions repo, to make them available via our extensions API.
* The Rust extension API crate, `zed-extension-api` has not yet been
published to crates.io, because we still consider the API a work in
progress.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-03-01 16:00:55 -08:00
Nathan Sobo
4cc4f08a53
Remove ! from todo!() in comments (#8643)
This practice makes it difficult to locate todo!s in my code when I'm
working. Let's take out the bang if we want to keep doing this.

Release Notes:

- N/A
2024-02-29 18:19:05 -07:00
Aryan Sjet
2f6b290084
linux: fix invalid cross-device link error (#8437)
This PR fix the "invalid cross-device link" error occurred in linux when
trying to write the settings file atomically, like when click the
"Enable vim mode" checkbox at first start.

```plain
[2024-02-26T22:59:25+08:00 ERROR util] .../zed/crates/settings/src/settings_file.rs:135: Failed to write settings to file "/home/$USER/.config/zed/settings.json"

Caused by:
0: failed to persist temporary file: Invalid cross-device link (os error 18)
1: Invalid cross-device link (os error 18)
```

Currently the `fs::RealFs::atomic_write()` method write to a temp file
created with `NamedTempFile::new()` and then call `persist()` method to
write to the config file path, which actually do a `rename` syscall
under the hood. As the
[issue](https://github.com/Stebalien/tempfile/issues/245) said

> `NamedTempFile::new()` will create a temporary file in your system's
temporary file directory. You need `NamedTempFile::new_in()`.

The temporary file directory in linux is in `/tmp`, which is mounted to
`tmpfs` filesystem, and in most case(all case I guess)
`$HOME/.config/zed` is mounted to a different filesystem. And the
`rename` syscall between different filesystems will return a `EXDEV`
errno, as described in the man page
[rename(2)](https://man7.org/linux/man-pages/man2/renameat2.2.html):

```plain
       EXDEV  oldpath and newpath are not on the same mounted
              filesystem.  (Linux permits a filesystem to be mounted at
              multiple points, but rename() does not work across
              different mount points, even if the same filesystem is
              mounted on both.)
```

And as the issue above said, use a different temp dir with
`NamedTempFile::new_in()` for linux platform might be a solution, since
the `rename` syscall provides atomicity.

Release Notes:
- Fix `settings.json` save failed with invalid cross-device link error
in linux
2024-02-27 21:49:28 -08:00
Dzmitry Malyshau
a44fc24445
Clean up many small dependencies (part 3) (#8425)
Follow-up to #8353

Release Notes:
- N/A
2024-02-26 11:08:57 +02:00
Small White
a475d8640f
Introduce file_id on Windows (#8130)
Added a function `file_id` to get the file id on windows, which is
similar to inode on unix.

Release Notes:

- N/A
2024-02-22 11:22:12 -08:00
Kirill Bulatov
c97ecc7326
Add initial CI job for Windows target (#8088)
Clippy is disabled for now, due to many warnings in both `gpui` and
other code, see
https://github.com/zed-industries/zed/actions/runs/7980269779/job/21789529800
for more details.

Also, due to `#!/usr/bin/env bash` shebang in the `script/clippy`, it
starts in Windows CI with `shell: C:\Program Files\Git\bin\bash.EXE
-euxo pipefail {0}`

https://github.com/zed-industries/zed/actions/runs/7980269779/job/21789529800#step:4:3
It seems more appropriate to use PowerShell instead.

See `todo!("windows")` for all stubbed places currently.

Release Notes:

- N/A
2024-02-21 00:35:29 +02:00
白山風露
77974a4367
Stubbing unix-dependent values on Windows (#8036)
Release Notes:

- N/A
2024-02-19 17:41:35 -08:00
Thorsten Ball
017b2db630
Fix case-only renaming of files (#7768)
This fixes #5211 and #7732 by fixing the case-only file renaming.

The fix here works by checking hooking into function that produces the
data to populate the project panel.

It checks whether we're on a case-insensitive file system (default on
macOS, but you can have case-sensitive FS on macOS too) and if so, it
ignores the metadata for files for which the absolute path (returned by
the FS scanner) and canonicalized path do NOT match.

That's the case for (a) symlinks and (b) case-only renames of files.

It only does this check for case-only renames.

Release Notes:

- Fixed case-only renaming of files producing duplicate entries in
project panel.
([#5211](https://github.com/zed-industries/zed/issues/5211)).

Co-authored-by: Antonio <antonio@zed.dev>
2024-02-14 16:00:31 +01:00
gmorenz
17c203fef9
Translate notify::Event to fsevent::Event on linux (#7545)
This isn't exactly a great solution, but it's a step in the right
direction, and it's simple allowing us to quickly unblock linux. Without
this (or an equivalent) PR linux builds are broken.

I spent a bunch of time investigating using notify on macos, and have a
branch with that working and FakeFs updated to use notify events.
unfortunately I think this would come with some drawbacks. Primarily
that files that don't yet exist yet aren't handled as well as with using
events directly leading to some less than ideal tradeoffs.

This PR is very much a placeholder for a better cross platform solution.
Most problematically, it only fills in the portion of fsevent::Event
that is currently used, despite there being a lot more information in
the ones collected from macos. At the very least a followup PR should
hide those implementation details behind a cross platform Event type so
that if people try and access data that hasn't been translated, they
find out about it.

Release Notes:

- N/A
2024-02-08 08:35:37 -08:00
Mikayla
67555ee5b4
Merge branch 'main' into kvark-linux 2024-02-07 11:52:44 -08:00
白山風露
42a5081aff
Use try_from_bytes for windows build (#7500)
Reduce windows build error.

Release Notes:

- N/A
2024-02-07 11:27:26 -05:00
Amin Yahyaabadi
d3562d4c9c
Fixes for file-watching, user assets, and system dependencies (#2)
* fix: avoid panics in case of non-existing path for watching

* fix: copy the themes and plugins

* Revert "add a few more libraries to the linux script"

This reverts commit 7509677003.

* fix: add vulkan validation layers to the system deps

* fix: fix the themes paths
2024-02-06 22:54:40 -08:00
Piotr Osiewicz
743f9b345f
chore: Move workspace dependencies to workspace.dependencies (#7454)
We should prefer referring to local deps via `.workspace = true` from
now on.

Release Notes:

- N/A
2024-02-06 20:41:36 +01:00
Amin Yahyaabadi
81bfa5fac4 fix: create the settings and keymaps to unblock file watching 2024-02-04 23:56:45 -08:00
Dzmitry Malyshau
8d339ede1c linux: HACK disable watcher and crash uploader temporarily 2024-02-04 20:23:06 -08:00
Marshall Bowers
e338f34097
Sort dependencies in Cargo.toml files (#7126)
This PR sorts the dependency lists in our `Cargo.toml` files so that
they are in alphabetical order.

This should make them easier to visually scan when looking for a
dependency.

Apologies in advance for any merge conflicts 🙈 

Release Notes:

- N/A
2024-01-30 21:41:29 -05:00
Marshall Bowers
176f63e86e
Add ability to copy a permalink to a line (#7119)
This PR adds the ability to copy the permalink to a line from within
Zed.

This functionality is available through the `editor: copy permalink to
line` action in the command palette:

<img width="589" alt="Screenshot 2024-01-30 at 7 07 46 PM"
src="https://github.com/zed-industries/zed/assets/1486634/332282cb-211f-4f16-9eb1-415bcfee9b7b">

Executing this action will create a permalink to the currently selected
line(s) and copy it to the clipboard.

Here is an example line:

```
56c80e8011/src/lib.rs (L25)
```

Currently, both GitHub and GitLab are supported.

### Notes and known limitations

- In order to determine where to permalink to, we read the URL of the
`origin` remote in Git. This feature will not work if the `origin`
remote is not present.
- Attempting to permalink to a ref that is not pushed to the origin will
result in the link 404ing.
- Attempting to permalink when Git is in a dirty state may not generate
the right link.
- For instance, modifying a file (e.g., adding new lines) and grabbing a
permalink to it will result in incorrect line numbers.

Release Notes:

- Added the ability to copy a permalink to a line
([#6777](https://github.com/zed-industries/zed/issues/6777)).
- Available via the `editor: copy permalink to line` action in the
command palette.
2024-01-30 19:20:15 -05:00
Marshall Bowers
0cb8b0e451
Clean up Cargo.toml files (#7044)
This PR cleans up some inconsistencies in the `Cargo.toml` files that
were driving me crazy.

Release Notes:

- N/A
2024-01-29 23:47:20 -05:00
Amin Yahyaabadi
1313402a6b
Introduce cross-platform file-watching (#6855)
This adds cross-platform file-watching via the
[Notify](https://github.com/notify-rs/notify) crate. The previous
fs-events implementation is now only used on MacOS, and on other
platforms Notify is used. The watching function interface is the same.

Related to #5391 #5395 #5394.

Release Notes:

- N/A
2024-01-29 22:18:10 +02:00
George Munyoro
49542757fd
Correctly check existence of target directory in copy_recursive function (#6875)
Fixes https://github.com/zed-industries/zed/issues/6778

Release Notes:

- Fixed issue where copy-paste for folders was not working in the
project panel
([#6778](https://github.com/zed-industries/zed/issues/6778)).
2024-01-29 12:06:02 +02:00
Piotr Osiewicz
0a0a866dd5
Licenses: change license fields in Cargo.toml to AGPL-3.0-or-later. (#5535)
Release Notes:
- N/A
2024-01-27 13:51:16 +01:00
Piotr Osiewicz
f2ff7fa4d5
chore: Change AGPL-licensed crates to GPL (except for collab) (#4231)
- [x] Fill in GPL license text.
- [x] live_kit_client depends on live_kit_server as non-dev dependency,
even though it seems to only be used for tests. Is that an issue?

Release Notes:
- N/A
2024-01-24 00:26:58 +01:00
Piotr Osiewicz
21e6b09361
Remove license-file from Cargo.toml as it is apparently redundant (#4218)
Release Notes:

- N/A
2024-01-23 17:40:30 +01:00
Piotr Osiewicz
678bdddd7d
chore: Add crate licenses. (#4158)
- GPUI and all dependencies: Apache 2
- Everything else: AGPL

Here's a script that I've generated for it:
https://gist.github.com/osiewicz/6afdd6626e517da24a2092807e6f0b6e

Release Notes:
- N/A

---------

Co-authored-by: David <david@zed.dev>
2024-01-23 16:56:22 +01:00
Piotr Osiewicz
6c82380232 chore: Fix clippy::needless_borrow up to an editor 2024-01-21 15:03:24 +01:00
Mikayla
57400e9687
Fix typos detected by crate-ci/typos 2024-01-17 14:31:21 -08:00
Max Brunsfeld
f5ba22659b Remove 2 suffix from gpui
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-01-03 12:59:39 -08:00
Max Brunsfeld
4305c5fdbe Remove 2 suffix for ui, storybook, text
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-01-03 12:33:51 -08:00
Max Brunsfeld
0cf65223ce Remove 2 suffix for collab, rope, settings, menu
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-01-03 12:29:16 -08:00
Max Brunsfeld
5ddd298b4d Remove 2 suffix for fs, db, semantic_index, prettier
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-01-03 12:09:42 -08:00
Kirill Bulatov
ce8cc50ae5 Remove async_trait from the only trait that allows it now 2023-12-28 23:45:30 +02:00
Kirill Bulatov
7aea95704e Revert unnecessary style changes 2023-10-12 16:17:41 +03:00
Kirill Bulatov
a8dfa01362 Prepare prettier file lookup code infra 2023-10-11 12:56:28 +03:00
Max Brunsfeld
17925ed563 Remove unnecessary dependencies on client and rpc 2023-10-06 13:14:53 -07:00
Marshall Bowers
9e1f7c4c18
Mainline GPUI2 UI work (#3079)
This PR mainlines the current state of new GPUI2-based UI from the
`gpui2-ui` branch.

Release Notes:

- N/A

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Nate <nate@zed.dev>
2023-10-02 18:20:47 -04:00
Conrad Irwin
2d9db0fed1 Flesh out v1.0 of vim : 2023-09-20 20:44:41 -06:00
KCaverly
d85acceeec move git2 to workspace dependency globally 2023-09-19 16:13:47 -04:00
Max Brunsfeld
46429426ef Avoid accidental gpui transitive dependency in collab
* Make Fs depend on Text, not vise versa

Co-authored-by: Joseph <joseph@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
2023-08-30 13:16:01 -07:00
Max Brunsfeld
8fff0b0ff8 Fix pathspec in staged_statuses
Enable non-literal matching so that directory paths match
all files contained within them.
2023-07-23 21:36:29 -07:00