File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ impl DaemonStateData {
4848 ws
4949 } ;
5050
51+ if let Some ( nvim) = workspace. clients . get ( & pid) {
52+ tracing:: debug!( "Update nvim state for project" ) ;
53+ nvim. exec_lua ( & workspace. project . nvim_update_state_script ( ) ?, vec ! [ ] )
54+ . await ?;
55+ }
56+
5157 tracing:: info!( "Managing [{}] {:?}" , workspace. project. name( ) , root) ;
5258
5359 self . workspaces . insert ( root. to_string ( ) , workspace) ;
Original file line number Diff line number Diff line change @@ -102,4 +102,13 @@ impl Project {
102102 pub fn targets ( & self ) -> & TargetMap {
103103 & self . targets
104104 }
105+
106+ #[ cfg( feature = "daemon" ) ]
107+ pub fn nvim_update_state_script ( & self ) -> anyhow:: Result < String > {
108+ Ok ( format ! (
109+ "require'xcodebase.state'.projects['{}'] = vim.json.decode([[{}]])" ,
110+ self . root. display( ) ,
111+ serde_json:: to_string( & self ) ?
112+ ) )
113+ }
105114}
Original file line number Diff line number Diff line change @@ -40,11 +40,12 @@ impl Workspace {
4040 . await
4141 . context ( "Fail to create xcodegen project." ) ?;
4242
43- let workspace = Self {
43+ let mut workspace = Self {
4444 root,
4545 project,
4646 clients : Default :: default ( ) ,
4747 } ;
48+ workspace. update_lua_state ( ) . await ?;
4849
4950 if !workspace. root . join ( ".compile" ) . is_file ( ) {
5051 tracing:: info!( ".compile doesn't exist, regenerating ..." ) ;
@@ -146,6 +147,7 @@ impl Workspace {
146147 {
147148 tracing:: info!( "Updating State.{}.Project" , self . name( ) ) ;
148149 self . project = Project :: new ( & self . root ) . await ?;
150+ self . update_lua_state ( ) . await ?;
149151 }
150152 return Ok ( ( ) ) ;
151153 }
@@ -156,6 +158,13 @@ impl Workspace {
156158 anyhow:: bail!( "Fail to update_xcodeproj" )
157159 }
158160
161+ async fn update_lua_state ( & mut self ) -> Result < ( ) > {
162+ let script = self . project . nvim_update_state_script ( ) ?;
163+ Ok ( for ( _, nvim) in self . clients . iter ( ) {
164+ nvim. exec_lua ( & script, vec ! [ ] ) . await ?;
165+ } )
166+ }
167+
159168 pub fn update_clients ( & mut self ) {
160169 let name = self . project . name ( ) ;
161170 self . clients . retain ( |pid, _| {
You can’t perform that action at this time.
0 commit comments