A simple CPU rendered GUI IDE experience.
Diffstat (limited to 'src/lsp/vsc_settings.rs')
| -rw-r--r-- | src/lsp/vsc_settings.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lsp/vsc_settings.rs b/src/lsp/vsc_settings.rs new file mode 100644 index 0000000..570ebe3 --- /dev/null +++ b/src/lsp/vsc_settings.rs @@ -0,0 +1,18 @@ +use std::path::Path; +use std::process::Stdio; + +use rootcause::prelude::ResultExt; +use rootcause::report; + +pub fn load(p: &Path, ws: &Path) -> rootcause::Result<serde_json::Value> { + let std::process::Output {stdout, stderr,.. } = std::process::Command::new("jq").stdout(Stdio::piped()) + .args(["-M", "-c", "-r", r#"reduce to_entries[] as $x ({}; setpath(($x.key | split(".")); $x.value)) | ."rust-analyzer""#, &p.to_string_lossy()]).spawn()?.wait_with_output() + ?; + let stdout = String::from_utf8(stdout)?.replace( + "${workspaceFolder}", + ws.to_str().ok_or(report!("bad path :("))?, + ); + Ok(serde_json::from_str(&stdout).context_with(move || { + String::from_utf8(stderr).unwrap_or("dang".into()) + })?) +} |