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
|
@ -994,19 +994,17 @@ impl Project {
|
|||
|
||||
let mut prettier_plugins_by_worktree = HashMap::default();
|
||||
for (worktree, language, settings) in language_formatters_to_check {
|
||||
if let Some(plugins) = prettier_support::prettier_plugins_for_language(
|
||||
&self.languages,
|
||||
&language,
|
||||
&settings,
|
||||
) {
|
||||
if let Some(plugins) =
|
||||
prettier_support::prettier_plugins_for_language(&language, &settings)
|
||||
{
|
||||
prettier_plugins_by_worktree
|
||||
.entry(worktree)
|
||||
.or_insert_with(|| HashSet::default())
|
||||
.extend(plugins);
|
||||
.extend(plugins.iter().cloned());
|
||||
}
|
||||
}
|
||||
for (worktree, prettier_plugins) in prettier_plugins_by_worktree {
|
||||
self.install_default_prettier(worktree, prettier_plugins, cx);
|
||||
self.install_default_prettier(worktree, prettier_plugins.into_iter(), cx);
|
||||
}
|
||||
|
||||
// Start all the newly-enabled language servers.
|
||||
|
@ -2845,12 +2843,10 @@ impl Project {
|
|||
let settings = language_settings(Some(&new_language), buffer_file.as_ref(), cx).clone();
|
||||
let buffer_file = File::from_dyn(buffer_file.as_ref());
|
||||
let worktree = buffer_file.as_ref().map(|f| f.worktree_id(cx));
|
||||
if let Some(prettier_plugins) = prettier_support::prettier_plugins_for_language(
|
||||
&self.languages,
|
||||
&new_language,
|
||||
&settings,
|
||||
) {
|
||||
self.install_default_prettier(worktree, prettier_plugins, cx);
|
||||
if let Some(prettier_plugins) =
|
||||
prettier_support::prettier_plugins_for_language(&new_language, &settings)
|
||||
{
|
||||
self.install_default_prettier(worktree, prettier_plugins.iter().cloned(), cx);
|
||||
};
|
||||
if let Some(file) = buffer_file {
|
||||
let worktree = file.worktree.clone();
|
||||
|
@ -3104,7 +3100,7 @@ impl Project {
|
|||
) -> Result<Arc<LanguageServer>> {
|
||||
let workspace_config =
|
||||
cx.update(|cx| adapter.workspace_configuration(worktree_path, cx))?;
|
||||
let language_server = pending_server.task.await?;
|
||||
let (language_server, mut initialization_options) = pending_server.task.await?;
|
||||
|
||||
let name = language_server.name();
|
||||
language_server
|
||||
|
@ -3344,7 +3340,6 @@ impl Project {
|
|||
})
|
||||
.detach();
|
||||
|
||||
let mut initialization_options = adapter.adapter.initialization_options();
|
||||
match (&mut initialization_options, override_options) {
|
||||
(Some(initialization_options), Some(override_options)) => {
|
||||
merge_json_value_into(override_options, initialization_options);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue