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>
28 lines
630 B
Rust
28 lines
630 B
Rust
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);
|