(ctx context.Context)
| 363 | } |
| 364 | |
| 365 | func (s *Server) RequestConfiguration(ctx context.Context) (lsutil.UserPreferences, error) { |
| 366 | caps := lsproto.GetClientCapabilities(ctx) |
| 367 | if !caps.Workspace.Configuration { |
| 368 | if opts := s.initializationOptions; opts.UserPreferences != nil { |
| 369 | userPrefs := *opts.UserPreferences |
| 370 | s.logger.Logf( |
| 371 | "received formatting options from initialization: %T\n%+v", |
| 372 | userPrefs, |
| 373 | userPrefs, |
| 374 | ) |
| 375 | if config, ok := userPrefs.(map[string]any); ok { |
| 376 | return lsutil.ParseUserPreferences(map[string]any{"js/ts": config}), nil |
| 377 | } |
| 378 | } |
| 379 | return lsutil.NewDefaultUserPreferences(), nil |
| 380 | } |
| 381 | configs, err := sendClientRequest(ctx, s, lsproto.WorkspaceConfigurationInfo, &lsproto.ConfigurationParams{ |
| 382 | Items: []*lsproto.ConfigurationItem{ |
| 383 | { |
| 384 | Section: new("js/ts"), |
| 385 | }, |
| 386 | { |
| 387 | Section: new("typescript"), |
| 388 | }, |
| 389 | { |
| 390 | Section: new("javascript"), |
| 391 | }, |
| 392 | { |
| 393 | Section: new("editor"), |
| 394 | }, |
| 395 | }, |
| 396 | }) |
| 397 | if err != nil { |
| 398 | return lsutil.UserPreferences{}, fmt.Errorf("configure request failed: %w", err) |
| 399 | } |
| 400 | configMap := map[string]any{} |
| 401 | for i, config := range configs { |
| 402 | switch i { |
| 403 | case 0: |
| 404 | configMap["js/ts"] = config |
| 405 | case 1: |
| 406 | configMap["typescript"] = config |
| 407 | case 2: |
| 408 | configMap["javascript"] = config |
| 409 | case 3: |
| 410 | configMap["editor"] = config |
| 411 | } |
| 412 | } |
| 413 | s.logger.Logf( |
| 414 | "received options from workspace/configuration request:\njs/ts: %+v\n\ntypescript: %+v\n\njavascript: %+v\n\neditor: %+v\n", |
| 415 | configMap["js/ts"], |
| 416 | configMap["typescript"], |
| 417 | configMap["javascript"], |
| 418 | configMap["editor"], |
| 419 | ) |
| 420 | return lsutil.ParseUserPreferences(configMap), nil |
| 421 | } |
| 422 |
no test coverage detected