Allow extensions to define more of the methods in the LspAdapter trait (#9554)
Our goal is to extract Svelte support into an extension, since we've seen problems with the Tree-sitter Svelte parser crashing due to bugs in the external scanner. In order to do this, we need a couple more capabilities in LSP extensions: * [x] `initialization_options` - programmatically controlling the JSON initialization params sent to the language server * [x] `prettier_plugins` - statically specifying a list of prettier plugins that apply for a given language. * [x] `npm_install_package` Release Notes: - N/A --------- Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
0ce5cdc48f
commit
d699b8e104
26 changed files with 318 additions and 208 deletions
|
@ -13,6 +13,14 @@ pub trait Extension: Send + Sync {
|
|||
config: wit::LanguageServerConfig,
|
||||
worktree: &wit::Worktree,
|
||||
) -> Result<Command>;
|
||||
|
||||
fn language_server_initialization_options(
|
||||
&mut self,
|
||||
_config: wit::LanguageServerConfig,
|
||||
_worktree: &wit::Worktree,
|
||||
) -> Result<Option<String>> {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
@ -60,4 +68,11 @@ impl wit::Guest for Component {
|
|||
) -> Result<wit::Command> {
|
||||
extension().language_server_command(config, worktree)
|
||||
}
|
||||
|
||||
fn language_server_initialization_options(
|
||||
config: LanguageServerConfig,
|
||||
worktree: &Worktree,
|
||||
) -> Result<Option<String>, String> {
|
||||
extension().language_server_initialization_options(config, worktree)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@ world extension {
|
|||
/// Gets the latest version of the given NPM package.
|
||||
import npm-package-latest-version: func(package-name: string) -> result<string, string>;
|
||||
|
||||
/// Returns the installed version of the given NPM package, if it exists.
|
||||
import npm-package-installed-version: func(package-name: string) -> result<option<string>, string>;
|
||||
|
||||
/// Installs the specified NPM package.
|
||||
import npm-install-package: func(package-name: string, version: string) -> result<_, string>;
|
||||
|
||||
/// Gets the latest release for the given GitHub repository.
|
||||
import latest-github-release: func(repo: string, options: github-release-options) -> result<github-release, string>;
|
||||
|
||||
|
@ -81,4 +87,5 @@ world extension {
|
|||
}
|
||||
|
||||
export language-server-command: func(config: language-server-config, worktree: borrow<worktree>) -> result<command, string>;
|
||||
export language-server-initialization-options: func(config: language-server-config, worktree: borrow<worktree>) -> result<option<string>, string>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue