@@ -27,11 +27,12 @@ pub struct Project<'a> {
2727 with_sysroot : bool ,
2828 tmp_dir : Option < TempDir > ,
2929 roots : Vec < PathBuf > ,
30+ config : Option < Box < dyn Fn ( & mut ServerConfig ) > > ,
3031}
3132
3233impl < ' a > Project < ' a > {
3334 pub fn with_fixture ( fixture : & str ) -> Project {
34- Project { fixture, tmp_dir : None , roots : vec ! [ ] , with_sysroot : false }
35+ Project { fixture, tmp_dir : None , roots : vec ! [ ] , with_sysroot : false , config : None }
3536 }
3637
3738 pub fn tmp_dir ( mut self , tmp_dir : TempDir ) -> Project < ' a > {
@@ -49,6 +50,11 @@ impl<'a> Project<'a> {
4950 self
5051 }
5152
53+ pub fn with_config ( mut self , config : impl Fn ( & mut ServerConfig ) + ' static ) -> Project < ' a > {
54+ self . config = Some ( Box :: new ( config) ) ;
55+ self
56+ }
57+
5258 pub fn server ( self ) -> Server {
5359 let tmp_dir = self . tmp_dir . unwrap_or_else ( || TempDir :: new ( ) . unwrap ( ) ) ;
5460 static INIT : Once = Once :: new ( ) ;
@@ -72,7 +78,14 @@ impl<'a> Project<'a> {
7278
7379 let roots = self . roots . into_iter ( ) . map ( |root| tmp_dir. path ( ) . join ( root) ) . collect ( ) ;
7480
75- Server :: new ( tmp_dir, self . with_sysroot , roots, paths)
81+ let mut config =
82+ ServerConfig { with_sysroot : self . with_sysroot , ..ServerConfig :: default ( ) } ;
83+
84+ if let Some ( f) = & self . config {
85+ f ( & mut config)
86+ }
87+
88+ Server :: new ( tmp_dir, config, roots, paths)
7689 }
7790}
7891
@@ -92,7 +105,7 @@ pub struct Server {
92105impl Server {
93106 fn new (
94107 dir : TempDir ,
95- with_sysroot : bool ,
108+ config : ServerConfig ,
96109 roots : Vec < PathBuf > ,
97110 files : Vec < ( PathBuf , String ) > ,
98111 ) -> Server {
@@ -118,7 +131,7 @@ impl Server {
118131 window : None ,
119132 experimental : None ,
120133 } ,
121- ServerConfig { with_sysroot , .. ServerConfig :: default ( ) } ,
134+ config ,
122135 connection,
123136 )
124137 . unwrap ( )
0 commit comments