Fix eslint diagnostics by passing worktree root during workspace init
This commit is contained in:
parent
02174084ca
commit
f9cd45269a
9 changed files with 45 additions and 16 deletions
|
@ -197,8 +197,12 @@ impl CachedLspAdapter {
|
||||||
self.adapter.code_action_kinds()
|
self.adapter.code_action_kinds()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workspace_configuration(&self, cx: &mut AppContext) -> BoxFuture<'static, Value> {
|
pub fn workspace_configuration(
|
||||||
self.adapter.workspace_configuration(cx)
|
&self,
|
||||||
|
workspace_root: &Path,
|
||||||
|
cx: &mut AppContext,
|
||||||
|
) -> BoxFuture<'static, Value> {
|
||||||
|
self.adapter.workspace_configuration(workspace_root, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
pub fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
||||||
|
@ -312,7 +316,7 @@ pub trait LspAdapter: 'static + Send + Sync {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn workspace_configuration(&self, _: &mut AppContext) -> BoxFuture<'static, Value> {
|
fn workspace_configuration(&self, _: &Path, _: &mut AppContext) -> BoxFuture<'static, Value> {
|
||||||
futures::future::ready(serde_json::json!({})).boxed()
|
futures::future::ready(serde_json::json!({})).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2641,8 +2641,9 @@ impl Project {
|
||||||
});
|
});
|
||||||
|
|
||||||
for (adapter, server) in servers {
|
for (adapter, server) in servers {
|
||||||
let workspace_config =
|
let workspace_config = cx
|
||||||
cx.update(|cx| adapter.workspace_configuration(cx)).await;
|
.update(|cx| adapter.workspace_configuration(server.root_path(), cx))
|
||||||
|
.await;
|
||||||
server
|
server
|
||||||
.notify::<lsp::notification::DidChangeConfiguration>(
|
.notify::<lsp::notification::DidChangeConfiguration>(
|
||||||
lsp::DidChangeConfigurationParams {
|
lsp::DidChangeConfigurationParams {
|
||||||
|
@ -2753,7 +2754,7 @@ impl Project {
|
||||||
stderr_capture.clone(),
|
stderr_capture.clone(),
|
||||||
language.clone(),
|
language.clone(),
|
||||||
adapter.clone(),
|
adapter.clone(),
|
||||||
worktree_path,
|
Arc::clone(&worktree_path),
|
||||||
ProjectLspAdapterDelegate::new(self, cx),
|
ProjectLspAdapterDelegate::new(self, cx),
|
||||||
cx,
|
cx,
|
||||||
) {
|
) {
|
||||||
|
@ -2776,6 +2777,7 @@ impl Project {
|
||||||
cx.spawn_weak(|this, mut cx| async move {
|
cx.spawn_weak(|this, mut cx| async move {
|
||||||
let result = Self::setup_and_insert_language_server(
|
let result = Self::setup_and_insert_language_server(
|
||||||
this,
|
this,
|
||||||
|
&worktree_path,
|
||||||
override_options,
|
override_options,
|
||||||
pending_server,
|
pending_server,
|
||||||
adapter.clone(),
|
adapter.clone(),
|
||||||
|
@ -2891,6 +2893,7 @@ impl Project {
|
||||||
|
|
||||||
async fn setup_and_insert_language_server(
|
async fn setup_and_insert_language_server(
|
||||||
this: WeakModelHandle<Self>,
|
this: WeakModelHandle<Self>,
|
||||||
|
worktree_path: &Path,
|
||||||
override_initialization_options: Option<serde_json::Value>,
|
override_initialization_options: Option<serde_json::Value>,
|
||||||
pending_server: PendingLanguageServer,
|
pending_server: PendingLanguageServer,
|
||||||
adapter: Arc<CachedLspAdapter>,
|
adapter: Arc<CachedLspAdapter>,
|
||||||
|
@ -2903,6 +2906,7 @@ impl Project {
|
||||||
this,
|
this,
|
||||||
override_initialization_options,
|
override_initialization_options,
|
||||||
pending_server,
|
pending_server,
|
||||||
|
worktree_path,
|
||||||
adapter.clone(),
|
adapter.clone(),
|
||||||
server_id,
|
server_id,
|
||||||
cx,
|
cx,
|
||||||
|
@ -2932,11 +2936,14 @@ impl Project {
|
||||||
this: WeakModelHandle<Self>,
|
this: WeakModelHandle<Self>,
|
||||||
override_options: Option<serde_json::Value>,
|
override_options: Option<serde_json::Value>,
|
||||||
pending_server: PendingLanguageServer,
|
pending_server: PendingLanguageServer,
|
||||||
|
worktree_path: &Path,
|
||||||
adapter: Arc<CachedLspAdapter>,
|
adapter: Arc<CachedLspAdapter>,
|
||||||
server_id: LanguageServerId,
|
server_id: LanguageServerId,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
) -> Result<Arc<LanguageServer>> {
|
) -> Result<Arc<LanguageServer>> {
|
||||||
let workspace_config = cx.update(|cx| adapter.workspace_configuration(cx)).await;
|
let workspace_config = cx
|
||||||
|
.update(|cx| adapter.workspace_configuration(worktree_path, cx))
|
||||||
|
.await;
|
||||||
let language_server = pending_server.task.await?;
|
let language_server = pending_server.task.await?;
|
||||||
|
|
||||||
language_server
|
language_server
|
||||||
|
@ -2964,11 +2971,14 @@ impl Project {
|
||||||
language_server
|
language_server
|
||||||
.on_request::<lsp::request::WorkspaceConfiguration, _, _>({
|
.on_request::<lsp::request::WorkspaceConfiguration, _, _>({
|
||||||
let adapter = adapter.clone();
|
let adapter = adapter.clone();
|
||||||
|
let worktree_path = worktree_path.to_path_buf();
|
||||||
move |params, mut cx| {
|
move |params, mut cx| {
|
||||||
let adapter = adapter.clone();
|
let adapter = adapter.clone();
|
||||||
|
let worktree_path = worktree_path.clone();
|
||||||
async move {
|
async move {
|
||||||
let workspace_config =
|
let workspace_config = cx
|
||||||
cx.update(|cx| adapter.workspace_configuration(cx)).await;
|
.update(|cx| adapter.workspace_configuration(&worktree_path, cx))
|
||||||
|
.await;
|
||||||
Ok(params
|
Ok(params
|
||||||
.items
|
.items
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -105,6 +105,7 @@ impl LspAdapter for JsonLspAdapter {
|
||||||
|
|
||||||
fn workspace_configuration(
|
fn workspace_configuration(
|
||||||
&self,
|
&self,
|
||||||
|
_workspace_root: &Path,
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> BoxFuture<'static, serde_json::Value> {
|
) -> BoxFuture<'static, serde_json::Value> {
|
||||||
let action_names = cx.all_action_names().collect::<Vec<_>>();
|
let action_names = cx.all_action_names().collect::<Vec<_>>();
|
||||||
|
|
|
@ -29,7 +29,6 @@ pub struct IntelephenseLspAdapter {
|
||||||
impl IntelephenseLspAdapter {
|
impl IntelephenseLspAdapter {
|
||||||
const SERVER_PATH: &'static str = "node_modules/intelephense/lib/intelephense.js";
|
const SERVER_PATH: &'static str = "node_modules/intelephense/lib/intelephense.js";
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
||||||
Self { node }
|
Self { node }
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,11 @@ impl LspAdapter for TailwindLspAdapter {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn workspace_configuration(&self, _: &mut AppContext) -> BoxFuture<'static, Value> {
|
fn workspace_configuration(
|
||||||
|
&self,
|
||||||
|
_workspace_root: &Path,
|
||||||
|
_: &mut AppContext,
|
||||||
|
) -> BoxFuture<'static, Value> {
|
||||||
future::ready(json!({
|
future::ready(json!({
|
||||||
"tailwindCSS": {
|
"tailwindCSS": {
|
||||||
"emmetCompletions": true,
|
"emmetCompletions": true,
|
||||||
|
|
|
@ -205,7 +205,6 @@ pub struct EsLintLspAdapter {
|
||||||
impl EsLintLspAdapter {
|
impl EsLintLspAdapter {
|
||||||
const SERVER_PATH: &'static str = "vscode-eslint/server/out/eslintServer.js";
|
const SERVER_PATH: &'static str = "vscode-eslint/server/out/eslintServer.js";
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
||||||
EsLintLspAdapter { node }
|
EsLintLspAdapter { node }
|
||||||
}
|
}
|
||||||
|
@ -213,13 +212,23 @@ impl EsLintLspAdapter {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl LspAdapter for EsLintLspAdapter {
|
impl LspAdapter for EsLintLspAdapter {
|
||||||
fn workspace_configuration(&self, _: &mut AppContext) -> BoxFuture<'static, Value> {
|
fn workspace_configuration(
|
||||||
|
&self,
|
||||||
|
workspace_root: &Path,
|
||||||
|
_: &mut AppContext,
|
||||||
|
) -> BoxFuture<'static, Value> {
|
||||||
future::ready(json!({
|
future::ready(json!({
|
||||||
"": {
|
"": {
|
||||||
"validate": "on",
|
"validate": "on",
|
||||||
"rulesCustomizations": [],
|
"rulesCustomizations": [],
|
||||||
"run": "onType",
|
"run": "onType",
|
||||||
"nodePath": null,
|
"nodePath": null,
|
||||||
|
"workingDirectory": {"mode": "auto"},
|
||||||
|
"workspaceFolder": {
|
||||||
|
"uri": workspace_root,
|
||||||
|
"name": workspace_root.file_name()
|
||||||
|
.unwrap_or_else(|| workspace_root.as_os_str()),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.boxed()
|
.boxed()
|
||||||
|
|
|
@ -93,7 +93,11 @@ impl LspAdapter for YamlLspAdapter {
|
||||||
) -> Option<LanguageServerBinary> {
|
) -> Option<LanguageServerBinary> {
|
||||||
get_cached_server_binary(container_dir, &*self.node).await
|
get_cached_server_binary(container_dir, &*self.node).await
|
||||||
}
|
}
|
||||||
fn workspace_configuration(&self, cx: &mut AppContext) -> BoxFuture<'static, Value> {
|
fn workspace_configuration(
|
||||||
|
&self,
|
||||||
|
_workspace_root: &Path,
|
||||||
|
cx: &mut AppContext,
|
||||||
|
) -> BoxFuture<'static, Value> {
|
||||||
let tab_size = all_language_settings(None, cx)
|
let tab_size = all_language_settings(None, cx)
|
||||||
.language(Some("YAML"))
|
.language(Some("YAML"))
|
||||||
.tab_size;
|
.tab_size;
|
||||||
|
|
|
@ -29,7 +29,6 @@ pub struct IntelephenseLspAdapter {
|
||||||
impl IntelephenseLspAdapter {
|
impl IntelephenseLspAdapter {
|
||||||
const SERVER_PATH: &'static str = "node_modules/intelephense/lib/intelephense.js";
|
const SERVER_PATH: &'static str = "node_modules/intelephense/lib/intelephense.js";
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
||||||
Self { node }
|
Self { node }
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,6 @@ pub struct EsLintLspAdapter {
|
||||||
impl EsLintLspAdapter {
|
impl EsLintLspAdapter {
|
||||||
const SERVER_PATH: &'static str = "vscode-eslint/server/out/eslintServer.js";
|
const SERVER_PATH: &'static str = "vscode-eslint/server/out/eslintServer.js";
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
||||||
EsLintLspAdapter { node }
|
EsLintLspAdapter { node }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue