diff --git a/helix-lsp/build.rs b/helix-lsp/build.rs new file mode 100644 index 0000000000000..914a942bd2ce3 --- /dev/null +++ b/helix-lsp/build.rs @@ -0,0 +1,22 @@ +use std::borrow::Cow; +use std::process::Command; + +const VERSION: &str = include_str!("../VERSION"); + +fn main() { + let git_hash = Command::new("git") + .args(["rev-parse", "HEAD"]) + .output() + .ok() + .filter(|output| output.status.success()) + .and_then(|x| String::from_utf8(x.stdout).ok()); + + let version: Cow<_> = match git_hash { + Some(git_hash) => format!("{} ({})", VERSION, &git_hash[..8]).into(), + None => VERSION.into(), + }; + + println!("cargo:rerun-if-changed=../VERSION"); + + println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version); +} diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 2c2c7c88ec1d0..bf06dccb6f9e3 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -376,7 +376,10 @@ impl Client { ..Default::default() }, trace: None, - client_info: None, + client_info: Some(lsp::ClientInfo { + name: String::from("helix"), + version: Some(String::from(env!("VERSION_AND_GIT_HASH"))), + }), locale: None, // TODO };