Skip to content

Commit

Permalink
feat(lsp): pass client_info on initialization
Browse files Browse the repository at this point in the history
Pass client name ('helix') and client version (version / git hash)
to LSP server on initialization.
  • Loading branch information
matoous committed Nov 26, 2022
1 parent fc81172 commit e783c49
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions helix-lsp/build.rs
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 4 additions & 1 deletion helix-lsp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit e783c49

Please sign in to comment.