Commit Graph

33 Commits

Author SHA1 Message Date
Thorsten Ball
a56a260778
Add ability to specify binary path/args for rust-analyzer (#9293)
This fixes #9292 by adding a section to the language server settings
that allows users to specify the binary path and arguments with which to
start up a language server.

Example user settings for `rust-analyzer`:

```json
{
  "lsp": {
    "rust-analyzer": {
      "binary": {
        "path": "/Users/thorstenball/tmp/rust-analyzer-aarch64-apple-darwin",
        "arguments": ["--no-log-buffering"]
      }
    }
  }
}
```

Constraints:

* Right now this only allows ABSOLUTE paths.
* This is only used by `rust-analyzer` integration right now, but the
setting can be used for other language servers. We just need to update
the adapters to also respect that setting.



Release Notes:

- Added ability to specify `rust-analyzer` binary `path` (must be
absolute) and `arguments` in user settings. Example: `{"lsp":
{"rust-analyzer": {"binary": {"path": "/my/abs/path/rust-analyzer",
"arguments": ["--no-log-buffering"] }}}}`
([#9292](https://github.com/zed-industries/zed/issues/9292)).

Co-authored-by: Ricard Mallafre <rikitzzz@gmail.com>
2024-03-13 18:42:03 +01:00
Max Brunsfeld
724c19a223
Add a setting for custom associations between languages and files (#9290)
Closes #5178

Release Notes:

- Added a `file_types` setting that can be used to associate languages
with file names and file extensions. For example, to interpret all `.c`
files as C++, and files called `MyLockFile` as TOML, add the following
to `settings.json`:

    ```json
    {
      "file_types": {
        "C++": ["c"],
        "TOML": ["MyLockFile"]
      }
    }
    ```

As with most zed settings, this can be configured on a per-directory
basis by including a local `.zed/settings.json` file in that directory.

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-13 10:23:30 -07:00
Max Brunsfeld
dfcc143ead
Rename 'project_core' crate to 'worktree', make it just about worktrees (#9189)
This is just a refactor. I noticed that we now have a `project_core`
crate, which mainly contains the `Worktree` type and its private
helpers, plus the project's settings.

In this PR, I've renamed that crate to `worktree` and did some minor
simplification to its module structure. I also extracted a new
`WorktreeSettings` settings type from the `ProjectSettings`, so that the
worktree settings could live in the worktree crate. This way, the crate
is now exclusively about worktree logic.

Release Notes:

- N/A
2024-03-11 11:35:27 -07: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
Max Brunsfeld
8a6264d933
Provide wasm extensions with APIs needed for using pre-installed LSP binaries (#9085)
In this PR, we've added two new methods that LSP extensions can call:
* `shell_env()`, for retrieving the environment variables set in the
user's default shell in the worktree
* `which(command)`, for looking up paths to an executable (accounting
for the user's shell env in the worktree)

To test this out, we moved the `uiua` language support into an
extension. We went ahead and removed the built-in support, since this
language is extremely obscure. Sorry @mikayla-maki. To continue coding
in Uiua in Zed, for now you can `Add Dev Extension` from the extensions
pane, and select the `extensions/uiua` directory in the Zed repo. Very
soon, we'll support publishing these extensions so that you'll be able
to just install it normally.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-08 17:18:06 -05:00
Max Brunsfeld
51ebe0eb01
Allow wasm extensions to do arbitrary file I/O in their own directory to install language servers (#9043)
This PR provides WASM extensions with write access to their own specific
working directory under the Zed `extensions` dir. This directory is set
as the extensions `current_dir` when they run. Extensions can return
relative paths from the `Extension::language_server_command` method, and
those relative paths will be interpreted relative to this working dir.

With this functionality, most language servers that we currently build
into zed can be installed using extensions.

Release Notes:

- N/A
2024-03-08 08:49:27 -08:00
Max Brunsfeld
27518f4280 Fix extension store test failure on main due to wasi-sdk download 2024-03-07 10:53:28 -08: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
Piotr Osiewicz
2201b9b116
task: Add task contexts (#8675)
This PR supplements tasks with additional environment variables; ideally
we'll be able to write a task like:
`cargo test -p $ZED_CURRENT_PACKAGE -- $ZED_CURRENT_FUNCTION`
- [x] Flesh out multibuffer interactions
- [x] Add ZED_SYMBOL detection based on tree-sitter queries
- [ ] Add release note and demo
- [x] Figure out a solution for rerun dilemma - should `task: rerun`
reevaluate contexts for tasks?

This PR introduced the following variables:
- ZED_COLUMN - current line column
- ZED_ROW - current line row
and the following, which are available for buffers with associated
files:
- ZED_WORKTREE_ROOT - absolute path to the root of the current worktree.
- ZED_FILE - absolute path to the file
- ZED_SYMBOL - currently selected symbol; should match the last symbol
shown in a symbol breadcrumb (e.g. `mod tests > fn test_task_contexts`
should be equal to ZED_SYMBOL of `test_task_contexts`). Note that this
isn't necessarily a test function or a function at all.

Also, you can use them in `cwd` field of definitions (note though that
we're using https://docs.rs/subst/latest/subst/#features for that, so
don't expect a full shell functionality to work); the syntax should
match up with your typical Unix shell.


Release Notes:

- Added task contexts, which are additional environment variables set by
Zed for task execution; task content is dependent on the state of the
editor at the time the task is spawned.

---------

Co-authored-by: Anthony <anthonyeid7@protonmail.com>
2024-03-04 21:04:53 +01:00
Marshall Bowers
33ef5b7731
Enable clippy::iter_kv_map (#8832)
This PR enables the
[`clippy::iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#/iter_kv_map)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-04 10:54:33 -05:00
Marshall Bowers
fe04f69caf
Enable clippy::useless_conversion (#8767)
This PR enables the
[`clippy::useless_conversion`](https://rust-lang.github.io/rust-clippy/master/index.html#/useless_conversion)
rule and fixes the outstanding violations.

Release Notes:

- N/A
2024-03-03 10:22:55 -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
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
Kirill Bulatov
882cd6e52f
Revert "Bump tree-sitter, wasmtime (#8306)" (#8373)
This reverts commit d4973846c0.

Fixes https://github.com/zed-industries/zed/issues/8360 and
https://github.com/zed-industries/zed/issues/8362


Release Notes:

- N/A
2024-02-25 10:35:19 +02:00
Max Brunsfeld
d4973846c0
Bump tree-sitter, wasmtime (#8306)
Fixes
https://github.com/zed-industries/zed/issues/8296#issuecomment-1961957369

Release Notes:

- Fixed a crash that would happen when loading an extension that added a
grammar that was generated using a very old version of Tree-sitter
([#8296](https://github.com/zed-industries/zed/issues/8296)).

---------

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
2024-02-24 14:24:29 -08:00
Marshall Bowers
ba4e1699ae
Rename ZedHttpClient for clarity (#8320)
This PR renames the `ZedHttpClient` to `HttpClientWithUrl` to make it
slightly clearer that it still is holding a `dyn HttpClient` as opposed
to being a concrete implementation.

Release Notes:

- N/A
2024-02-24 00:07:24 -05:00
Marshall Bowers
c59aab5090
Adjust labels of buttons in extension list based on status (#8319)
This PR makes the labels of the buttons in the extension list adapt to
reflect the current status.

Release Notes:

- Changed the button labels in the extension list to reflect the current
status.
2024-02-23 21:53:14 -05:00
Conrad Irwin
351e6a5de2
Expose extensions API from api.zed.dev (#8307)
This avoids the need to pay for bandwidth

Co-Authored-By: Marshall <marshall@zed.dev>



Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-23 16:08:14 -05:00
Conrad Irwin
58fd84308d
Disable swift for now (#8291)
It causes segfaults on load

Release Notes:

- Fixed a segfault opening a Swift file with the Swift extension
installed.
2024-02-23 11:04:48 -07:00
Marshall Bowers
af06063d31
Add checkbox to only show installed extensions (#8208)
This PR adds a checkbox to the extensions view to allow filtering to
just extensions that are installed:

<img width="1408" alt="Screenshot 2024-02-22 at 12 05 40 PM"
src="https://github.com/zed-industries/zed/assets/1486634/b5e82941-53be-432e-bfe5-fec7fd0959c5">

Release Notes:

- Added a checkbox to the extensions view to only show installed
extensions.
2024-02-22 12:16:02 -05:00
Ivan Buryak
7bf16f263e
Fix a bug when extension loading is failed after it's folder is viewed by MacOS finder (#8111)
Fixes #8096

# Bug description

I was experimenting with adding extensions and almost went crazy trying
to make my demo extension work. It appeared that I was copying files
with Finder that creates hidden `.DS_Store` files which interfered with
Zed's loading logic. It assumes that `languages/` directory contains
only directories and never files and so it crashes when meets
`.DS_Store`. This makes any extension stop working after it has been
viewed via Finder

# Change

Check if path is directory when loading extension languages (so it will
skip .DS_Store files)
2024-02-21 08:46:58 -08:00
Marshall Bowers
3cbc18895a
Upgrade toml to v0.8 (#7931)
This PR upgrades our `toml` dependency to v0.8.

I noticed that our current version of `toml` wasn't able to parse
certain kinds of documents involving enums, whereas the newer version
can.

Release Notes:

- N/A
2024-02-16 17:43:40 -05:00
Marshall Bowers
23132b5ab1
Display extension download counts (#7864)
This PR adds the download count for extensions to the extensions view.

Release Notes:

- Added download counts for extensions to the extensions view.
2024-02-15 16:41:54 -05:00
Max Brunsfeld
c357e37dde
Reload extensions more robustly when manually modifying installed extensions directory (#7749)
Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-13 16:15:19 -08:00
Marshall Bowers
c3176392c6
Remove themes from the registry when the extension is uninstalled (#7745)
This PR makes it so uninstalling an extension will remove any themes
provided by that extension from the theme registry.

Release Notes:

- N/A
2024-02-13 16:41:34 -05:00
Max Brunsfeld
e73e93f333
Unload languages when uninstalling their extension (#7743)
Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-13 15:25:54 -05:00
Carlos Lopez
fecb5a82f1
Add an extensions installation view (#7689)
This PR adds a view for installing extensions within Zed.

My subtasks:

- [X] Page Extensions and assign in App Menu
- [X] List extensions 
- [X] Button to Install/Uninstall
- [x] Search Input to search in extensions registry API
- [x] Get Extensions from API
- [x] Action install to download extension and copy in /extensions
folder
- [x] Action uninstall to remove from /extensions folder
- [x] Filtering
- [x] Better UI Design

Open to collab!

Release Notes:

- Added an extension installation view. Open it using the `zed:
extensions` action in the command palette
([#7096](https://github.com/zed-industries/zed/issues/7096)).

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Carlos <foxkdev@gmail.com>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Co-authored-by: Max <max@zed.dev>
2024-02-13 14:09:02 -05:00
Max Brunsfeld
36b89571e9
Add binary for exporting JSON schemas for validating extensions (#7639)
Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-09 18:50:41 -05:00
Max Brunsfeld
ed54665711
Cleanup logic for registering languages and grammars (#7593)
This is a refactor, follow-up to the work we've been doing on loading
WASM language extensions.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-08 16:24:49 -05:00
Max Brunsfeld
7b03e977e4
Reload grammars in extensions when they are updated on disk (#7531)
Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Co-authored-by: Marshall <marshall@zed.dev>
2024-02-07 16:39:11 -08:00
Marshall Bowers
2f4bb79553
Reload themes defined in extensions (#7520)
This PR extends the extension directory watcher to also watch and reload
themes defined in extensions.

Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
2024-02-07 16:11:24 -05:00
Max Brunsfeld
6edeea7c8a
Add logic for managing language and theme extensions (#7467)
This PR adds the initial support for loading extensions in Zed.

### Extensions Directory

Extensions are loaded from the extensions directory.

The extensions directory has the following structure:

```
extensions/
  installed/
    extension-a/
      grammars/
      languages/
    extension-b/
      themes/
  manifest.json
```

The `manifest.json` file is used internally by Zed to keep track of
which extensions are installed. This file should be maintained
automatically, and shouldn't require any direct interaction with it.

Extensions can provide Tree-sitter grammars, languages, and themes.

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-07 15:14:50 -05:00