@@ -218,7 +218,7 @@ func (s *Server) RefreshDiagnostics(ctx context.Context) error {
218
218
return nil
219
219
}
220
220
221
- func (s * Server ) Configure (ctx context.Context ) (* ls.UserPreferences , error ) {
221
+ func (s * Server ) RequestConfiguration (ctx context.Context ) (* ls.UserPreferences , error ) {
222
222
result , err := s .sendRequest (ctx , lsproto .MethodWorkspaceConfiguration , & lsproto.ConfigurationParams {
223
223
Items : []* lsproto.ConfigurationItem {
224
224
{
@@ -233,14 +233,8 @@ func (s *Server) Configure(ctx context.Context) (*ls.UserPreferences, error) {
233
233
s .Log (fmt .Sprintf ("\n \n configuration: %+v, %T\n \n " , configs , configs ))
234
234
userPreferences := ls .NewDefaultUserPreferences ()
235
235
for _ , item := range configs {
236
- if item == nil {
237
- // continue
238
- } else if config , ok := item .(map [string ]any ); ok {
239
- userPreferences .Parse (config )
240
- } else if item , ok := item .(ls.UserPreferences ); ok {
241
- // case for fourslash
242
- userPreferences = & item
243
- break
236
+ if parsed := userPreferences .Parse (item ); parsed != nil {
237
+ return parsed , nil
244
238
}
245
239
}
246
240
return userPreferences , nil
@@ -696,11 +690,15 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali
696
690
NpmExecutor : s ,
697
691
ParseCache : s .parseCache ,
698
692
})
699
- userPreferences , err := s .Configure (ctx )
700
- if err != nil {
701
- return err
693
+
694
+ // request userPreferences if not provided at initialization
695
+ if s .session .UserPreferences () == nil {
696
+ userPreferences , err := s .RequestConfiguration (ctx )
697
+ if err != nil {
698
+ return err
699
+ }
700
+ s .session .Configure (userPreferences )
702
701
}
703
- s .session .Configure (userPreferences )
704
702
// !!! temporary; remove when we have `handleDidChangeConfiguration`/implicit project config support
705
703
if s .compilerOptionsForInferredProjects != nil {
706
704
s .session .DidChangeCompilerOptionsForInferredProjects (ctx , s .compilerOptionsForInferredProjects )
@@ -719,12 +717,11 @@ func (s *Server) handleExit(ctx context.Context, params any) error {
719
717
}
720
718
721
719
func (s * Server ) handleDidChangeWorkspaceConfiguration (ctx context.Context , params * lsproto.DidChangeConfigurationParams ) error {
722
- // !!! update user preferences
723
- // !!! only usable by fourslash
724
- if item , ok := params .Settings .(* ls.UserPreferences ); ok {
725
- // case for fourslash
726
- s .session .Configure (item )
720
+ userPreferences := s .session .UserPreferences ().CopyOrDefault ()
721
+ if parsed := userPreferences .Parse (params .Settings ); parsed != nil {
722
+ userPreferences = parsed
727
723
}
724
+ s .session .Configure (userPreferences )
728
725
return nil
729
726
}
730
727
0 commit comments