@@ -88,7 +88,6 @@ enum SyntheticRunLevel {
88
88
impl LanguageServer for Backend {
89
89
async fn initialize ( & self , params : InitializeParams ) -> Result < InitializeResult > {
90
90
self . init ( params. root_uri ) ?;
91
- self . init_ignore_glob ( ) . await ;
92
91
let options = params. initialization_options . and_then ( |mut value| {
93
92
let settings = value. get_mut ( "settings" ) ?. take ( ) ;
94
93
serde_json:: from_value :: < Options > ( settings) . ok ( )
@@ -117,7 +116,8 @@ impl LanguageServer for Backend {
117
116
None
118
117
} ;
119
118
120
- self . init_linter_config ( ) . await ;
119
+ let oxlintrc = self . init_linter_config ( ) . await ;
120
+ self . init_ignore_glob ( oxlintrc) . await ;
121
121
Ok ( InitializeResult {
122
122
server_info : Some ( ServerInfo { name : "oxc" . into ( ) , version : None } ) ,
123
123
offset_encoding : None ,
@@ -330,7 +330,7 @@ impl Backend {
330
330
Ok ( ( ) )
331
331
}
332
332
333
- async fn init_ignore_glob ( & self ) {
333
+ async fn init_ignore_glob ( & self , oxlintrc : Option < Oxlintrc > ) {
334
334
let uri = self
335
335
. root_uri
336
336
. get ( )
@@ -366,6 +366,17 @@ impl Backend {
366
366
}
367
367
}
368
368
}
369
+
370
+ if let Some ( oxlintrc) = oxlintrc {
371
+ if !oxlintrc. ignore_patterns . is_empty ( ) {
372
+ let mut builder =
373
+ ignore:: gitignore:: GitignoreBuilder :: new ( oxlintrc. path . parent ( ) . unwrap ( ) ) ;
374
+ for entry in & oxlintrc. ignore_patterns {
375
+ builder. add_line ( None , entry) . expect ( "Failed to add ignore line" ) ;
376
+ }
377
+ gitignore_globs. push ( builder. build ( ) . unwrap ( ) ) ;
378
+ }
379
+ }
369
380
}
370
381
371
382
#[ allow( clippy:: ptr_arg) ]
@@ -389,12 +400,12 @@ impl Backend {
389
400
. await ;
390
401
}
391
402
392
- async fn init_linter_config ( & self ) {
403
+ async fn init_linter_config ( & self ) -> Option < Oxlintrc > {
393
404
let Some ( Some ( uri) ) = self . root_uri . get ( ) else {
394
- return ;
405
+ return None ;
395
406
} ;
396
407
let Ok ( root_path) = uri. to_file_path ( ) else {
397
- return ;
408
+ return None ;
398
409
} ;
399
410
let mut config_path = None ;
400
411
let config = root_path. join ( self . options . lock ( ) . await . get_config_path ( ) . unwrap ( ) ) ;
@@ -403,16 +414,17 @@ impl Backend {
403
414
}
404
415
if let Some ( config_path) = config_path {
405
416
let mut linter = self . server_linter . write ( ) . await ;
417
+ let config = Oxlintrc :: from_file ( & config_path)
418
+ . expect ( "should have initialized linter with new options" ) ;
406
419
* linter = ServerLinter :: new_with_linter (
407
- LinterBuilder :: from_oxlintrc (
408
- true ,
409
- Oxlintrc :: from_file ( & config_path)
410
- . expect ( "should have initialized linter with new options" ) ,
411
- )
412
- . with_fix ( FixKind :: SafeFix )
413
- . build ( ) ,
420
+ LinterBuilder :: from_oxlintrc ( true , config. clone ( ) )
421
+ . with_fix ( FixKind :: SafeFix )
422
+ . build ( ) ,
414
423
) ;
424
+ return Some ( config) ;
415
425
}
426
+
427
+ None
416
428
}
417
429
418
430
async fn handle_file_update ( & self , uri : Url , content : Option < String > , version : Option < i32 > ) {
0 commit comments