File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,24 @@ use std::{
1515
1616#[ derive( Clone ) ]
1717pub struct LanguageClient {
18- pub version : String ,
19- pub state_mutex : Arc < Mutex < State > > ,
20- pub clients_mutex : Arc < Mutex < HashMap < LanguageId , Arc < Mutex < ( ) > > > > > ,
18+ version : String ,
19+ state_mutex : Arc < Mutex < State > > ,
20+ clients_mutex : Arc < Mutex < HashMap < LanguageId , Arc < Mutex < ( ) > > > > > ,
2121}
2222
2323impl LanguageClient {
24+ pub fn new ( version : String , state : State ) -> Self {
25+ LanguageClient {
26+ version,
27+ state_mutex : Arc :: new ( Mutex :: new ( state) ) ,
28+ clients_mutex : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
29+ }
30+ }
31+
32+ pub fn version ( & self ) -> String {
33+ self . version . clone ( )
34+ }
35+
2436 // NOTE: Don't expose this as public.
2537 // MutexGuard could easily halt the program when one guard is not released immediately after use.
2638 fn lock ( & self ) -> Result < MutexGuard < State > > {
Original file line number Diff line number Diff line change @@ -1108,7 +1108,7 @@ impl LanguageClient {
11081108 InitializeParams {
11091109 client_info : Some ( ClientInfo {
11101110 name : "LanguageClient-neovim" . into ( ) ,
1111- version : Some ( self . version . clone ( ) ) ,
1111+ version : Some ( self . version ( ) ) ,
11121112 } ) ,
11131113 process_id : Some ( u64:: from ( std:: process:: id ( ) ) ) ,
11141114 /* deprecated in lsp types, but can't initialize without it */
Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ mod vimext;
1313mod watcher;
1414
1515use anyhow:: Result ;
16- use std:: collections:: HashMap ;
17- use std:: sync:: { Arc , Mutex } ;
16+ use language_client:: LanguageClient ;
1817use types:: State ;
1918
2019#[ macro_use]
@@ -26,11 +25,8 @@ fn main() -> Result<()> {
2625 let _ = clap:: app_from_crate!( ) . get_matches ( ) ;
2726
2827 let ( tx, rx) = crossbeam:: channel:: unbounded ( ) ;
29- let language_client = language_client:: LanguageClient {
30- version : env ! ( "CARGO_PKG_VERSION" ) . into ( ) ,
31- state_mutex : Arc :: new ( Mutex :: new ( State :: new ( tx) ?) ) ,
32- clients_mutex : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
33- } ;
34-
28+ let version = env ! ( "CARGO_PKG_VERSION" ) . into ( ) ;
29+ let state = State :: new ( tx) ?;
30+ let language_client = LanguageClient :: new ( version, state) ;
3531 language_client. loop_call ( & rx)
3632}
You can’t perform that action at this time.
0 commit comments