Open a buffer for every language server error when clicking on status
This commit is contained in:
parent
7239aac532
commit
4e4210ac39
9 changed files with 180 additions and 109 deletions
|
@ -39,10 +39,12 @@ pub async fn npm_package_latest_version(name: &str) -> Result<String> {
|
|||
let output = smol::process::Command::new("npm")
|
||||
.args(["info", name, "--json"])
|
||||
.output()
|
||||
.await?;
|
||||
.await
|
||||
.context("failed to run npm info")?;
|
||||
if !output.status.success() {
|
||||
Err(anyhow!(
|
||||
"failed to execute npm info: {:?}",
|
||||
"failed to execute npm info:\nstdout: {:?}\nstderr: {:?}",
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
))?;
|
||||
}
|
||||
|
@ -71,7 +73,8 @@ pub async fn npm_install_packages(
|
|||
.context("failed to run npm install")?;
|
||||
if !output.status.success() {
|
||||
Err(anyhow!(
|
||||
"failed to execute npm install: {:?}",
|
||||
"failed to execute npm install:\nstdout: {:?}\nstderr: {:?}",
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
))?;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use super::installation::{npm_install_packages, npm_package_latest_version};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use client::http::HttpClient;
|
||||
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
||||
use language::{LanguageServerName, LspAdapter};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use smol::fs;
|
||||
use std::{
|
||||
|
@ -33,25 +33,7 @@ impl LspAdapter for JsonLspAdapter {
|
|||
_: Arc<dyn HttpClient>,
|
||||
) -> BoxFuture<'static, Result<Box<dyn 'static + Any + Send>>> {
|
||||
async move {
|
||||
#[derive(Deserialize)]
|
||||
struct NpmInfo {
|
||||
versions: Vec<String>,
|
||||
}
|
||||
|
||||
let output = smol::process::Command::new("npm")
|
||||
.args(["info", "vscode-json-languageserver", "--json"])
|
||||
.output()
|
||||
.await?;
|
||||
if !output.status.success() {
|
||||
Err(anyhow!("failed to execute npm info"))?;
|
||||
}
|
||||
let mut info: NpmInfo = serde_json::from_slice(&output.stdout)?;
|
||||
|
||||
Ok(Box::new(
|
||||
info.versions
|
||||
.pop()
|
||||
.ok_or_else(|| anyhow!("no versions found in npm info"))?,
|
||||
) as Box<_>)
|
||||
Ok(Box::new(npm_package_latest_version("vscode-json-languageserver").await?) as Box<_>)
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
|
@ -71,16 +53,11 @@ impl LspAdapter for JsonLspAdapter {
|
|||
let binary_path = version_dir.join(Self::BIN_PATH);
|
||||
|
||||
if fs::metadata(&binary_path).await.is_err() {
|
||||
let output = smol::process::Command::new("npm")
|
||||
.current_dir(&version_dir)
|
||||
.arg("install")
|
||||
.arg(format!("vscode-json-languageserver@{}", version))
|
||||
.output()
|
||||
.await
|
||||
.context("failed to run npm install")?;
|
||||
if !output.status.success() {
|
||||
Err(anyhow!("failed to install vscode-json-languageserver"))?;
|
||||
}
|
||||
npm_install_packages(
|
||||
[("vscode-json-languageserver", version.as_str())],
|
||||
&version_dir,
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(mut entries) = fs::read_dir(&container_dir).await.log_err() {
|
||||
while let Some(entry) = entries.next().await {
|
||||
|
|
|
@ -129,7 +129,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||
},
|
||||
);
|
||||
|
||||
workspace::lsp_status::init(cx);
|
||||
lsp_status::init(cx);
|
||||
settings::KeymapFileContent::load_defaults(cx);
|
||||
}
|
||||
|
||||
|
@ -209,9 +209,7 @@ pub fn initialize_workspace(
|
|||
|
||||
let diagnostic_summary =
|
||||
cx.add_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace.project(), cx));
|
||||
let lsp_status = cx.add_view(|cx| {
|
||||
workspace::lsp_status::LspStatus::new(workspace.project(), app_state.languages.clone(), cx)
|
||||
});
|
||||
let lsp_status = lsp_status::LspStatusItem::new(workspace, app_state.languages.clone(), cx);
|
||||
let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
|
||||
let auto_update = cx.add_view(|cx| auto_update::AutoUpdateIndicator::new(cx));
|
||||
let feedback_link = cx.add_view(|_| feedback::FeedbackLink);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue