From 4c182216c7c28dbf40070f630bafb4cf890b7ea3 Mon Sep 17 00:00:00 2001 From: cgxxv Date: Thu, 13 Jun 2024 21:20:53 +0800 Subject: [PATCH] Support golang tools locally --- rust-toolchain | 2 +- src/main.rs | 14 +++++++++++++- volt.toml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index bf867e0..2bf5ad0 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly +stable diff --git a/src/main.rs b/src/main.rs index ece91bc..7389d1c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,13 +84,25 @@ fn initialize(params: InitializeParams) -> Result<()> { } } } - + for tool in tools::ALL_TOOLS_INFORMATION { + #[cfg(windows)] + let exists = PLUGIN_RPC.execute_process(string!("where"), vec![tool.name.to_string()])?.success; + #[cfg(not(windows))] + let exists = PLUGIN_RPC.execute_process(string!("which"), vec![tool.name.to_string()])?.success; + + if exists { + PLUGIN_RPC.stderr(&format!("{} exists, SKIPPED.", tool.import_path)); + continue; + } + if !PLUGIN_RPC .execute_process(string!("go"), vec![string!("install"), tool.install_path()])? .success { return Err(anyhow!("Failed to install tool: {}", tool.name)); + } else { + PLUGIN_RPC.stderr(&format!("Installing {}@{} SUCCEED", tool.import_path, tool.default_version.unwrap_or("latest"))); } } diff --git a/volt.toml b/volt.toml index a773881..cf88007 100644 --- a/volt.toml +++ b/volt.toml @@ -1,5 +1,5 @@ name = "lapce-go" -version = "2023.1.0" +version = "2024.1.0" author = "panekj" display-name = "Go (gopls)" description = "Go for Lapce using gopls"