diff --git a/Cargo.lock b/Cargo.lock index afd7067..8017dba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,10 @@ name = "cc" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" +dependencies = [ + "jobserver", + "libc", +] [[package]] name = "cfg-if" @@ -114,6 +118,7 @@ name = "discord-presence-lsp" version = "0.1.0" dependencies = [ "discord-rich-presence", + "git2", "tokio", "tower-lsp", ] @@ -239,6 +244,21 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +[[package]] +name = "git2" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" +dependencies = [ + "bitflags 2.6.0", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -299,6 +319,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + [[package]] name = "leb128" version = "0.2.5" @@ -311,6 +340,46 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libgit2-sys" +version = "0.17.0+1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + +[[package]] +name = "libssh2-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c15da26e5af7e25c90b37a2d75cdbf940cf4a55316de9d84c679c9b8bfabf82e" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -391,6 +460,24 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -452,6 +539,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "proc-macro2" version = "1.0.86" @@ -802,6 +895,12 @@ dependencies = [ "getrandom", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/lsp/Cargo.toml b/lsp/Cargo.toml index de9a17c..1dfffbe 100644 --- a/lsp/Cargo.toml +++ b/lsp/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" discord-rich-presence = "0.2.4" tokio = { version = "1.37.0", features = ["full"] } tower-lsp = "0.20.0" +git2 = "0.19.0" diff --git a/lsp/src/discord.rs b/lsp/src/discord.rs index a31af12..148b559 100644 --- a/lsp/src/discord.rs +++ b/lsp/src/discord.rs @@ -4,7 +4,7 @@ use std::{ }; use discord_rich_presence::{ - activity::{self, Assets, Timestamps}, + activity::{self, Assets, Button, Timestamps}, DiscordIpc, DiscordIpcClient, }; @@ -41,10 +41,11 @@ impl Discord { result.unwrap(); } - pub fn change_file(&self, filename: &str, workspace: &str) { + pub fn change_file(&self, filename: &str, workspace: &str, git_remote_url: Option) { self.change_activity( format!("Working on {}", filename), format!("In {}", workspace), + git_remote_url, ) } @@ -52,20 +53,27 @@ impl Discord { return self.client.lock().expect("Failed to lock discord client"); } - fn change_activity(&self, state: String, details: String) { + fn change_activity(&self, state: String, details: String, git_remote_url: Option) { let mut client = self.get_client(); let timestamp: i64 = self.start_timestamp.as_millis() as i64; + let mut buttons: Vec