@@ -21,6 +21,7 @@ pub(crate) struct ResolvedClientSettings {
21
21
lint_enable : bool ,
22
22
disable_rule_comment_enable : bool ,
23
23
fix_violation_enable : bool ,
24
+ show_syntax_errors : bool ,
24
25
editor_settings : ResolvedEditorSettings ,
25
26
}
26
27
@@ -70,6 +71,13 @@ pub struct ClientSettings {
70
71
exclude : Option < Vec < String > > ,
71
72
line_length : Option < LineLength > ,
72
73
configuration_preference : Option < ConfigurationPreference > ,
74
+
75
+ /// If `true` or [`None`], show syntax errors as diagnostics.
76
+ ///
77
+ /// This is useful when using Ruff with other language servers, allowing the user to refer
78
+ /// to syntax errors from only one source.
79
+ show_syntax_errors : Option < bool > ,
80
+
73
81
// These settings are only needed for tracing, and are only read from the global configuration.
74
82
// These will not be in the resolved settings.
75
83
#[ serde( flatten) ]
@@ -244,6 +252,11 @@ impl ResolvedClientSettings {
244
252
} ,
245
253
true ,
246
254
) ,
255
+ show_syntax_errors : Self :: resolve_or (
256
+ all_settings,
257
+ |settings| settings. show_syntax_errors ,
258
+ true ,
259
+ ) ,
247
260
editor_settings : ResolvedEditorSettings {
248
261
configuration : Self :: resolve_optional ( all_settings, |settings| {
249
262
settings
@@ -345,6 +358,10 @@ impl ResolvedClientSettings {
345
358
self . fix_violation_enable
346
359
}
347
360
361
+ pub ( crate ) fn show_syntax_errors ( & self ) -> bool {
362
+ self . show_syntax_errors
363
+ }
364
+
348
365
pub ( crate ) fn editor_settings ( & self ) -> & ResolvedEditorSettings {
349
366
& self . editor_settings
350
367
}
@@ -439,6 +456,7 @@ mod tests {
439
456
exclude: None,
440
457
line_length: None,
441
458
configuration_preference: None,
459
+ show_syntax_errors: None,
442
460
tracing: TracingSettings {
443
461
log_level: None,
444
462
log_file: None,
@@ -491,6 +509,7 @@ mod tests {
491
509
exclude: None,
492
510
line_length: None,
493
511
configuration_preference: None,
512
+ show_syntax_errors: None,
494
513
tracing: TracingSettings {
495
514
log_level: None,
496
515
log_file: None,
@@ -556,6 +575,7 @@ mod tests {
556
575
exclude: None,
557
576
line_length: None,
558
577
configuration_preference: None,
578
+ show_syntax_errors: None,
559
579
tracing: TracingSettings {
560
580
log_level: None,
561
581
log_file: None,
@@ -602,6 +622,7 @@ mod tests {
602
622
lint_enable: true ,
603
623
disable_rule_comment_enable: false ,
604
624
fix_violation_enable: false ,
625
+ show_syntax_errors: true ,
605
626
editor_settings: ResolvedEditorSettings {
606
627
configuration: None ,
607
628
lint_preview: Some ( true ) ,
@@ -633,6 +654,7 @@ mod tests {
633
654
lint_enable: true ,
634
655
disable_rule_comment_enable: true ,
635
656
fix_violation_enable: false ,
657
+ show_syntax_errors: true ,
636
658
editor_settings: ResolvedEditorSettings {
637
659
configuration: None ,
638
660
lint_preview: Some ( false ) ,
@@ -700,6 +722,7 @@ mod tests {
700
722
),
701
723
),
702
724
configuration_preference: None,
725
+ show_syntax_errors: None,
703
726
tracing: TracingSettings {
704
727
log_level: Some(
705
728
Warn,
@@ -726,6 +749,7 @@ mod tests {
726
749
lint_enable: true ,
727
750
disable_rule_comment_enable: false ,
728
751
fix_violation_enable: true ,
752
+ show_syntax_errors: true ,
729
753
editor_settings: ResolvedEditorSettings {
730
754
configuration: None ,
731
755
lint_preview: None ,
0 commit comments