language: Allow support for ESLint working directories (#43677)

Closes #9648 #9755

Release Notes:

- Added way to configure ESLint's working directories in settings. For
example:
`{"lsp":{"eslint":{"settings":{"workingDirectories":["./client","./server"]}}}}`

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
Smit Barmase
2025-11-28 19:40:23 +05:30
committed by GitHub
co-authored by Piotr Osiewicz
parent 478bcea6d3
commit 7c967b8d1a
14 changed files with 837 additions and 260 deletions
+35 -15
View File
@@ -436,6 +436,7 @@ impl LocalLspStore {
adapter.adapter.clone(),
&delegate,
toolchain,
None,
cx,
)
.await?;
@@ -720,25 +721,42 @@ impl LocalLspStore {
)
})?
.context("Expected the LSP store to be in a local mode")?;
let workspace_config = Self::workspace_configuration_for_adapter(
adapter.clone(),
&delegate,
toolchain_for_id,
&mut cx,
)
.await?;
let mut scope_uri_to_workspace_config = BTreeMap::new();
for item in &params.items {
let scope_uri = item.scope_uri.clone();
let std::collections::btree_map::Entry::Vacant(new_scope_uri) =
scope_uri_to_workspace_config.entry(scope_uri.clone())
else {
// We've already queried workspace configuration of this URI.
continue;
};
let workspace_config = Self::workspace_configuration_for_adapter(
adapter.clone(),
&delegate,
toolchain_for_id.clone(),
scope_uri,
&mut cx,
)
.await?;
new_scope_uri.insert(workspace_config);
}
Ok(params
.items
.into_iter()
.map(|item| {
.filter_map(|item| {
let workspace_config =
scope_uri_to_workspace_config.get(&item.scope_uri)?;
if let Some(section) = &item.section {
workspace_config
.get(section)
.cloned()
.unwrap_or(serde_json::Value::Null)
Some(
workspace_config
.get(section)
.cloned()
.unwrap_or(serde_json::Value::Null),
)
} else {
workspace_config.clone()
Some(workspace_config.clone())
}
})
.collect())
@@ -3527,11 +3545,12 @@ impl LocalLspStore {
adapter: Arc<dyn LspAdapter>,
delegate: &Arc<dyn LspAdapterDelegate>,
toolchain: Option<Toolchain>,
requested_uri: Option<Uri>,
cx: &mut AsyncApp,
) -> Result<serde_json::Value> {
let mut workspace_config = adapter
.clone()
.workspace_configuration(delegate, toolchain, cx)
.workspace_configuration(delegate, toolchain, requested_uri, cx)
.await?;
for other_adapter in delegate.registered_lsp_adapters() {
@@ -7963,6 +7982,7 @@ impl LspStore {
adapter.adapter.clone(),
&delegate,
toolchain,
None,
cx,
)
.await
@@ -13619,7 +13639,7 @@ pub fn language_server_settings<'a>(
)
}
pub(crate) fn language_server_settings_for<'a>(
pub fn language_server_settings_for<'a>(
location: SettingsLocation<'a>,
language: &LanguageServerName,
cx: &'a App,