Commit Graph

36 Commits

Author SHA1 Message Date
Marshall Bowers
61e4b6413a
zed_extension_api: Return structured slash command completions (#13879)
This PR updates the extension API to use structured slash command
completions instead of plain strings.

This allows slash commands defined in extensions to take advantage of
the improvements made in #13876.

Release Notes:

- N/A
2024-07-05 14:08:42 -04:00
Marshall Bowers
6d10b16f79
gleam: Include a package name suffix for docs entries (#13798)
This PR updates the Gleam docs provider to include the package name as a
suffix for docs entries:

<img width="639" alt="Screenshot 2024-07-03 at 5 48 28 PM"
src="https://github.com/zed-industries/zed/assets/1486634/0d98ffba-fbab-4511-ae16-e1e742d56f93">

This will help disambiguate modules with the same names from different
packages, as well as help out with providing better completions when the
package name and top-level module name do not match.

Release Notes:

- N/A
2024-07-03 17:56:01 -04:00
Marshall Bowers
98699a65c1
gleam: Improve indexing of HexDocs (#13787)
This PR improves the indexing of HexDocs content for Gleam packages.

We now index each of the modules in the package instead of just the
root.

Release Notes:

- N/A
2024-07-03 12:57:08 -04:00
Marshall Bowers
089cc85d4a
Use a dedicated test extension in extension tests (#13781)
This PR updates the `extension` crate's tests to use a dedicated test
extension for its tests instead of the real Gleam extension.

As the Gleam extension continues to evolve, it makes it less suitable to
use as a test fixture:

1. For a while now, the test has failed locally due to me having `gleam`
on my $PATH, which causes the extension's `get_language_server_command`
to go down a separate codepath.
2. With the addition of the `indexed_docs_providers` the test was
hanging indefinitely.

While these problems are likely solvable, it seems reasonable to have a
dedicated extension to use as a test fixture. That way we can do
whatever we need to exercise our test criteria.

The `test-extension` is a fork of the Gleam extension with some
additional functionality removed.

Release Notes:

- N/A
2024-07-03 11:10:51 -04:00
Marshall Bowers
5c7a8f779a
Allow extensions to define providers for indexing docs (#13755)
This PR provides extensions with the ability to define providers for
indexing docs.

Release Notes:

- N/A
2024-07-02 19:49:20 -04:00
Marshall Bowers
ecd9422d11
gleam: Add /gleam-docs (#13721)
This PR adds a `/gleam-docs` slash command to the Gleam extension, which
can be used to fetch docs from HexDocs.

Release Notes:

- N/A
2024-07-01 17:58:21 -04:00
Marshall Bowers
db0d843fb1
Allow completing slash command arguments from extensions (#13240)
This PR extends the extension API with support for completing slash
command arguments for slash commands defined in extensions.

Release Notes:

- N/A
2024-06-18 17:58:57 -04:00
Marshall Bowers
ad4e52842c
Make slash commands defined in extensions return SlashCommandOutput (#13237)
This PR extends the interface for slash commands defined in extensions
to have them return `SlashCommandOutput`.

This allows for slash commands to return multiple output sections for a
single piece of generated text.

Note that we don't allow specifying the icon to display in the
placeholder, as we don't want to commit to that in our API at the
moment.

Release Notes:

- N/A
2024-06-18 17:28:01 -04: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
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
Piotr Osiewicz
27229bba6b
tasks: Provide task variables from matching runnable ranges in task modal (#12237)
In #12003 we found ourselves in need for precise region tracking in
which a given runnable has an effect in order to grab variables from it.
This PR makes it so that in task modal all task variables from queries
overlapping current cursor position.
However, in the process of working on that I've found that we cannot
always use a top-level capture to represent the full match range of
runnable (which has been my assumption up to this point). Tree-sitter
captures cannot capture sibling groups; we did just that in Rust
queries.

Thankfully, none of the extensions are affected as in them, a capture is
always attached to single node. This PR adds annotations to them
nonetheless; we'll be able to get rid of top-level captures in extension
runnables.scm once this PR is in stable version of Zed.


Release Notes:

- N/A
2024-05-24 21:00:23 +02:00
Marshall Bowers
e0cfba43aa
gleam: Detect tests using describe API for Startest (#12221)
This PR updates the Gleam runnables to detect tests using the `describe`
API in Startest.

This isn't entirely functional yet, as it is still just uses the test
function name to run the tests (which Startest doesn't yet support).

Release Notes:

- N/A
2024-05-23 17:20:06 -04:00
Marshall Bowers
99c6389ff8
gleam: Bump to v0.1.3 (#12000)
This PR bumps the Gleam extension to v0.1.3.

Changes:

- #11998

Release Notes:

- N/A
2024-05-17 16:31:01 -04:00
d1y
0325051629
gleam: Update tree-sitter-gleam (#11998)
#11996

Release Notes:

- N/A
2024-05-17 16:21:44 -04:00
Marshall Bowers
652748b0c9
gleam: Bump to v0.1.2 (#11803)
This PR bumps the Gleam extension to v0.1.2.

Changes:

- #11476
- #11801

Release Notes:

- N/A
2024-05-14 10:53:43 -04:00
Marshall Bowers
77f0d35684
gleam: Add gleam test task (#11801)
This PR adds a task for running `gleam test`.

Release Notes:

- N/A
2024-05-14 10:45:14 -04:00
Marshall Bowers
4eca7875ae
gleam: Add runnable tests (#11476)
This PR adds basic runnable tests for Gleam.

Functions with names ending in `_test` will be available for running:


https://github.com/zed-industries/zed/assets/1486634/9f3f81e5-a7fa-425c-a5a2-d615062486bb

Release Notes:

- N/A
2024-05-06 22:26:36 -04:00
Marshall Bowers
4c35cfaa69
gleam: Bump to v0.1.1 (#10648)
This PR bumps the Gleam extension to v0.1.1.

Changes:

- #10635

Release Notes:

- N/A
2024-04-16 15:21:14 -04:00
Marshall Bowers
53105ddd16
gleam: Don't cache user-installed gleam (#10635)
This PR updates the Gleam extension to not cache the binary when it is
using the one on the $PATH.

Release Notes:

- N/A
2024-04-16 13:11:58 -04:00
Marshall Bowers
3a6e0bb9b6
gleam: Bump to v0.1.0 (#10376)
This PR bumps the Gleam extension to v0.1.0.

This version of the Gleam extension brings improved completion labels:

<img width="572" alt="Screenshot 2024-04-10 at 3 30 25 PM"
src="https://github.com/zed-industries/zed/assets/1486634/afca4563-c520-4f01-949f-2c8095769751">

Release Notes:

- N/A
2024-04-10 15:33:22 -04:00
Marshall Bowers
b6857ca469
Use v0.0.6 of the zed_extension_api for extensions that need it (#10324)
This PR updates the extensions dependent on v0.0.6 of the
`zed_extension_api` crate to use the now-published version on crates.io
instead of a path dependency.

The impacted extensions are:

- `dart`
- `gleam`
- `haskell`
- `svelte`


Release Notes:

- N/A
2024-04-09 10:57:26 -04:00
Marshall Bowers
a4566c36a3
gleam: Strip newlines in completion details returned from language server (#10304)
This PR updates the Gleam extension to strip out newlines in the
completion details returned from the language server.

These newlines were causing the completion menu to compute a large
height for each item, resulting in lots of empty space in the completion
menu:

<img width="878" alt="Screenshot 2024-04-08 at 8 53 29 PM"
src="https://github.com/zed-industries/zed/assets/1486634/383c52ec-e5cb-4496-ae4c-28744b4ecaf5">

The approach to stripping newlines allocates a bit more than I would
like.

It would be good to see if it is possible for the Gleam language server
to not send us these newlines in the first place.

Release Notes:

- N/A
2024-04-08 21:43:18 -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
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
Marshall Bowers
90cf73b746
Update extension descriptions (#9939)
This PR updates the descriptions of some of the extensions to match the
others.

Release Notes:

- N/A
2024-03-28 17:14:55 -04:00
Marshall Bowers
687d2a41d6
gleam: Bump to v0.0.2 (#9883)
This PR bumps the Gleam extension to v0.0.2.

Release Notes:

- N/A
2024-03-27 14:47:37 -04:00
Marshall Bowers
95699a07f4
gleam: Check for gleam on the PATH before installing the latest version (#9882)
This PR updates the Gleam extension to give priority to the `gleam`
binary that is already on the PATH before downloading/installing a
separate Gleam version.

Release Notes:

- N/A
2024-03-27 14:25:18 -04: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
Max Brunsfeld
585e8671e3
Add a schema to extensions, to prevent installing extensions on too old of a Zed version (#9599)
Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-20 17:33:26 -04:00
Max Brunsfeld
fd11bd68f2
Perform extension packaging in extension-cli (#9549)
Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-03-19 17:26:06 -04: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
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
d7962aa2d3
Add license to Gleam extension (#8730)
This PR adds a license to the Gleam extension crate, since the bundling
script was unhappy that it didn't have one.

Since extensions like this one may ultimately live outside of Zed
itself, I went with the Apache 2.0 license.

Release Notes:

- N/A
2024-03-02 17:56:57 -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