Correctly merge settings for vtsls (#17657)
Release Notes: - Fixed vtsls initialization_options in project settings files
This commit is contained in:
parent
bd1ff476b9
commit
130f19d8f9
1 changed files with 20 additions and 8 deletions
|
@ -7,14 +7,14 @@ use lsp::{CodeActionKind, LanguageServerBinary};
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
use project::project_settings::{BinarySettings, ProjectSettings};
|
use project::project_settings::{BinarySettings, ProjectSettings};
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use settings::Settings;
|
use settings::{Settings, SettingsLocation};
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::{maybe, ResultExt};
|
use util::{maybe, merge_json_value_into, ResultExt};
|
||||||
|
|
||||||
fn typescript_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
fn typescript_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||||
vec![server_path.into(), "--stdio".into()]
|
vec![server_path.into(), "--stdio".into()]
|
||||||
|
@ -274,7 +274,13 @@ impl LspAdapter for VtslsLspAdapter {
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
) -> Result<Value> {
|
) -> Result<Value> {
|
||||||
let override_options = cx.update(|cx| {
|
let override_options = cx.update(|cx| {
|
||||||
ProjectSettings::get_global(cx)
|
ProjectSettings::get(
|
||||||
|
Some(SettingsLocation {
|
||||||
|
worktree_id: adapter.worktree_id(),
|
||||||
|
path: adapter.worktree_root_path(),
|
||||||
|
}),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
.lsp
|
.lsp
|
||||||
.get(SERVER_NAME)
|
.get(SERVER_NAME)
|
||||||
.and_then(|s| s.initialization_options.clone())
|
.and_then(|s| s.initialization_options.clone())
|
||||||
|
@ -282,9 +288,15 @@ impl LspAdapter for VtslsLspAdapter {
|
||||||
if let Some(options) = override_options {
|
if let Some(options) = override_options {
|
||||||
return Ok(options);
|
return Ok(options);
|
||||||
}
|
}
|
||||||
self.initialization_options(adapter)
|
let mut initialization_options = self
|
||||||
|
.initialization_options(adapter)
|
||||||
.await
|
.await
|
||||||
.map(|o| o.unwrap())
|
.map(|o| o.unwrap())?;
|
||||||
|
|
||||||
|
if let Some(override_options) = override_options {
|
||||||
|
merge_json_value_into(override_options, &mut initialization_options)
|
||||||
|
}
|
||||||
|
Ok(initialization_options)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn language_ids(&self) -> HashMap<String, String> {
|
fn language_ids(&self) -> HashMap<String, String> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue