File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ tracing = { workspace = true }
2626tracing-appender = { workspace = true }
2727tracing-subscriber = { workspace = true }
2828
29+ [build-dependencies ]
30+ toml = { workspace = true }
31+
2932[dev-dependencies ]
3033tempfile = { workspace = true }
3134
Original file line number Diff line number Diff line change 1+ use std:: env;
2+ use std:: fs;
3+ use std:: path:: PathBuf ;
4+
5+ fn main ( ) {
6+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
7+
8+ let workspace_dir = env:: var ( "CARGO_WORKSPACE_DIR" ) . expect ( "CARGO_WORKSPACE_DIR not set" ) ;
9+ let djls_cargo_toml = PathBuf :: from ( workspace_dir)
10+ . join ( "crates" )
11+ . join ( "djls" )
12+ . join ( "Cargo.toml" ) ;
13+
14+ println ! ( "cargo:rerun-if-changed={}" , djls_cargo_toml. display( ) ) ;
15+
16+ let contents = fs:: read_to_string ( & djls_cargo_toml)
17+ . unwrap_or_else ( |_| panic ! ( "Failed to read {}" , djls_cargo_toml. display( ) ) ) ;
18+
19+ let cargo_toml: toml:: Value = toml:: from_str ( & contents)
20+ . unwrap_or_else ( |_| panic ! ( "Failed to parse {}" , djls_cargo_toml. display( ) ) ) ;
21+
22+ let version = cargo_toml
23+ . get ( "package" )
24+ . and_then ( |p| p. get ( "version" ) )
25+ . and_then ( |v| v. as_str ( ) )
26+ . expect ( "Failed to extract version from djls Cargo.toml" ) ;
27+
28+ println ! ( "cargo:rustc-env=DJLS_VERSION={version}" ) ;
29+ }
Original file line number Diff line number Diff line change @@ -21,9 +21,6 @@ use crate::queue::Queue;
2121use crate :: session:: Session ;
2222use crate :: session:: SessionSnapshot ;
2323
24- const SERVER_NAME : & str = "Django Language Server" ;
25- const SERVER_VERSION : & str = "0.1.0" ;
26-
2724pub struct DjangoLanguageServer {
2825 client : Client ,
2926 session : Arc < Mutex < Session > > ,
@@ -168,8 +165,8 @@ impl LanguageServer for DjangoLanguageServer {
168165 ..Default :: default ( )
169166 } ,
170167 server_info : Some ( lsp_types:: ServerInfo {
171- name : SERVER_NAME . to_string ( ) ,
172- version : Some ( SERVER_VERSION . to_string ( ) ) ,
168+ name : "Django Language Server" . to_string ( ) ,
169+ version : Some ( env ! ( "DJLS_VERSION" ) . to_string ( ) ) ,
173170 } ) ,
174171 offset_encoding : Some ( encoding. to_string ( ) ) ,
175172 } )
You can’t perform that action at this time.
0 commit comments