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>
This commit is contained in:
parent
5abcc1c3c5
commit
8a6264d933
23 changed files with 235 additions and 256 deletions
16
extensions/uiua/Cargo.toml
Normal file
16
extensions/uiua/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[package]
|
||||
name = "zed_uiua"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "Apache-2.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
zed_extension_api = { path = "../../crates/extension_api" }
|
||||
|
||||
[lib]
|
||||
path = "src/uiua.rs"
|
||||
crate-type = ["cdylib"]
|
13
extensions/uiua/extension.toml
Normal file
13
extensions/uiua/extension.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
id = "uiua"
|
||||
name = "Uiua"
|
||||
description = "Uiua support for Zed"
|
||||
version = "0.0.1"
|
||||
authors = ["Max Brunsfeld <max@zed.dev>"]
|
||||
|
||||
[language_servers.uiua]
|
||||
name = "Uiua LSP"
|
||||
language = "Uiua"
|
||||
|
||||
[grammars.uiua]
|
||||
repository = "https://github.com/shnarazk/tree-sitter-uiua"
|
||||
commit = "21dc2db39494585bf29a3f86d5add6e9d11a22ba"
|
11
extensions/uiua/languages/uiua/config.toml
Normal file
11
extensions/uiua/languages/uiua/config.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
name = "Uiua"
|
||||
grammar = "uiua"
|
||||
path_suffixes = ["ua"]
|
||||
line_comments = ["# "]
|
||||
autoclose_before = ")]}\""
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = false},
|
||||
{ start = "[", end = "]", close = true, newline = false },
|
||||
{ start = "(", end = ")", close = true, newline = false },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
|
||||
]
|
50
extensions/uiua/languages/uiua/highlights.scm
Normal file
50
extensions/uiua/languages/uiua/highlights.scm
Normal file
|
@ -0,0 +1,50 @@
|
|||
[
|
||||
(openParen)
|
||||
(closeParen)
|
||||
(openCurly)
|
||||
(closeCurly)
|
||||
(openBracket)
|
||||
(closeBracket)
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
(branchSeparator)
|
||||
(underscore)
|
||||
] @constructor
|
||||
; ] @punctuation.delimiter
|
||||
|
||||
[ (character) ] @constant.character
|
||||
[ (comment) ] @comment
|
||||
[ (constant) ] @constant.numeric
|
||||
[ (identifier) ] @variable
|
||||
[ (leftArrow) ] @keyword
|
||||
[ (function) ] @function
|
||||
[ (modifier1) ] @operator
|
||||
[ (modifier2) ] @operator
|
||||
[ (number) ] @constant.numeric
|
||||
[ (placeHolder) ] @special
|
||||
[ (otherConstant) ] @string.special
|
||||
[ (signature) ] @type
|
||||
[ (system) ] @function.builtin
|
||||
[ (tripleMinus) ] @module
|
||||
|
||||
; planet
|
||||
[
|
||||
"id"
|
||||
"identity"
|
||||
"∘"
|
||||
"dip"
|
||||
"⊙"
|
||||
"gap"
|
||||
"⋅"
|
||||
] @tag
|
||||
|
||||
[
|
||||
(string)
|
||||
(multiLineString)
|
||||
] @string
|
||||
|
||||
; [
|
||||
; (deprecated)
|
||||
; (identifierDeprecated)
|
||||
; ] @warning
|
3
extensions/uiua/languages/uiua/indents.scm
Normal file
3
extensions/uiua/languages/uiua/indents.scm
Normal file
|
@ -0,0 +1,3 @@
|
|||
[
|
||||
(array)
|
||||
] @indent
|
27
extensions/uiua/src/uiua.rs
Normal file
27
extensions/uiua/src/uiua.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use zed_extension_api::{self as zed, Result};
|
||||
|
||||
struct UiuaExtension;
|
||||
|
||||
impl zed::Extension for UiuaExtension {
|
||||
fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
|
||||
fn language_server_command(
|
||||
&mut self,
|
||||
_config: zed::LanguageServerConfig,
|
||||
worktree: &zed::Worktree,
|
||||
) -> Result<zed::Command> {
|
||||
let path = worktree
|
||||
.which("uiua")
|
||||
.ok_or_else(|| "uiua is not installed".to_string())?;
|
||||
|
||||
Ok(zed::Command {
|
||||
command: path,
|
||||
args: vec!["lsp".to_string()],
|
||||
env: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
zed::register_extension!(UiuaExtension);
|
Loading…
Add table
Add a link
Reference in a new issue