Declarative extensions #28430
Replies: 3 comments 5 replies
-
|
@maxnordlund I like the direction of your thinking! I wonder if you have thought more about this question: What are some good ways to provide a declarative syntax that can coexist with fully custom extensions -- even in the same extension? If there is a good design for this, it can offer a nice range of options -- kind of an "a la carte" set of options. |
Beta Was this translation helpful? Give feedback.
-
|
As a meta-response, it would be very interesting to write an automated analysis program that ingested all Zed extensions and then surfaced common elements of extensions. This could provide data for exploring different declarative extension designs and choices. Maybe even think of it sort of like a "linting" or "automated migration" feature ... it would guide an extension author towards reusing common declarative blocks (when suitable). |
Beta Was this translation helpful? Give feedback.
-
|
Note that this will only be relevant for extensions which download from GitHub releases, many extensions will use an NPM package instead. Would there start to be multiple declarations for different options? Having a good example or small crate for extensions to use could be an alternative idea. The real issue here is that the fish extension has not been touched in a year despite it receiving pull requests, including from the Zed team, and also that it does not register a language server to begin with. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been using Zed as my main editor for a few months now and really appreciate all the thought that went in to the fundamentals behind the extensions (e.g. using WASM/WASI).
However I've noticed the official/well maintained ones supports downloading language servers1, while the less polished ones2 does not. So I read through their source and realized they look very boilerplatey. This makes me think that most of the current set of features can be done declaratively in the
extension.toml.Let's take the Elixir extension as an example. It supports three different LSP's, but with varying level of support for their settings. Only Lexical seems to support custom startup arguments. But I digress, here's the extension manifest at the time of writing this:
extension.toml
The code for
next-lsis in https://github.com/zed-extensions/elixir/blob/main/src/language_servers/next_ls.rsNow imagine we could specify that in TOML instead:
I'm sure I've glossed over some intricate detail that makes this less then straight forward. Some will still need the full power of being compiled, but I believe that most extensions could be reduced to being purely declarative. The extension code could either be generated on the fly, or some sort of generic implementation for declarative extensions only. The former would be backwards compatible, which is nice.
The real upside would be support for more features across the board. I'm mostly thinking of the customization of the sever command, arguments, and environment. But also customization of the initialization request sent in the very beginning (for example to enable/disable completion or inline formatting), and sending a "workspace configuration" request shortly after. These customization's vary wildly between different extensions, and even within one. Only one of the three language servers in the Elixir extension supports custom server arguments, and as far as I can see, none supports customization of the server environment.
Footnotes
Among other features, mostly regarding starting and configuring language servers. ↩
It doesn't have an LSP, but there's a PR for it. ↩
Beta Was this translation helpful? Give feedback.
All reactions