@@ -61,6 +61,14 @@ export interface WorkspaceConfigInterface {
6161 * @default {}
6262 */
6363 flags : Record < string , string > ;
64+
65+ /**
66+ * Enable formatting experiment
67+ * `oxc.fmt.experimental`
68+ *
69+ * @default false
70+ */
71+ [ 'fmt.experimental' ] : boolean ;
6472}
6573
6674export class WorkspaceConfig {
@@ -70,6 +78,7 @@ export class WorkspaceConfig {
7078 private _unusedDisableDirectives : UnusedDisableDirectives = 'allow' ;
7179 private _typeAware : boolean = false ;
7280 private _flags : Record < string , string > = { } ;
81+ private _formattingExperimental : boolean = false ;
7382
7483 constructor ( private readonly workspace : WorkspaceFolder ) {
7584 this . refresh ( ) ;
@@ -91,6 +100,7 @@ export class WorkspaceConfig {
91100 'allow' ;
92101 this . _typeAware = this . configuration . get < boolean > ( 'typeAware' ) ?? false ;
93102 this . _flags = flags ;
103+ this . _formattingExperimental = this . configuration . get < boolean > ( 'fmt.experimental' ) ?? false ;
94104 }
95105
96106 public effectsConfigChange ( event : ConfigurationChangeEvent ) : boolean {
@@ -112,6 +122,9 @@ export class WorkspaceConfig {
112122 if ( event . affectsConfiguration ( `${ ConfigService . namespace } .flags` , this . workspace ) ) {
113123 return true ;
114124 }
125+ if ( event . affectsConfiguration ( `${ ConfigService . namespace } .fmt.experimental` , this . workspace ) ) {
126+ return true ;
127+ }
115128 return false ;
116129 }
117130
@@ -173,6 +186,15 @@ export class WorkspaceConfig {
173186 return this . configuration . update ( 'flags' , value , ConfigurationTarget . WorkspaceFolder ) ;
174187 }
175188
189+ get formattingExperimental ( ) : boolean {
190+ return this . _formattingExperimental ;
191+ }
192+
193+ updateFormattingExperimental ( value : boolean ) : PromiseLike < void > {
194+ this . _formattingExperimental = value ;
195+ return this . configuration . update ( 'fmt.experimental' , value , ConfigurationTarget . WorkspaceFolder ) ;
196+ }
197+
176198 public toLanguageServerConfig ( ) : WorkspaceConfigInterface {
177199 return {
178200 run : this . runTrigger ,
@@ -181,6 +203,7 @@ export class WorkspaceConfig {
181203 unusedDisableDirectives : this . unusedDisableDirectives ,
182204 typeAware : this . typeAware ,
183205 flags : this . flags ,
206+ [ 'fmt.experimental' ] : this . formattingExperimental ,
184207 } ;
185208 }
186209}
0 commit comments