| 37 | } |
| 38 | |
| 39 | func (s *Server) Initialize(ctx *glsp.Context, params *protocol.InitializeParams) (any, error) { |
| 40 | bytes, err := json.Marshal(params.Capabilities.Experimental) |
| 41 | if err == nil { |
| 42 | _ = json.Unmarshal(bytes, &s.capabilities) |
| 43 | } |
| 44 | if params.ClientInfo != nil { |
| 45 | s.sessionTelemetryProperties["lsp_client_info_name"] = params.ClientInfo.Name |
| 46 | if params.ClientInfo.Version != nil { |
| 47 | s.sessionTelemetryProperties["lsp_client_info_version"] = *params.ClientInfo.Version |
| 48 | } |
| 49 | if s.capabilities != nil { |
| 50 | if s.capabilities.Capabilities.ClientInfoExtras.ClientName != "" { |
| 51 | s.sessionTelemetryProperties["client_name"] = s.capabilities.Capabilities.ClientInfoExtras.ClientName |
| 52 | } |
| 53 | if s.capabilities.Capabilities.ClientInfoExtras.ClientSession != "" { |
| 54 | s.sessionTelemetryProperties["client_session"] = s.capabilities.Capabilities.ClientInfoExtras.ClientSession |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | s.Enqueue(telemetry.EventServerHeartbeat, map[string]any{ |
| 59 | "type": telemetry.ServerHeartbeatTypeInitialized, |
| 60 | }) |
| 61 | |
| 62 | s.client = &LanguageClient{call: ctx.Call, notify: ctx.Notify} |
| 63 | |
| 64 | workspaceFolders := []string{} |
| 65 | for _, workspaceFolder := range params.WorkspaceFolders { |
| 66 | path, err := urlPath(workspaceFolder.URI) |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | workspaceFolders = append(workspaceFolders, path) |
| 71 | } |
| 72 | |
| 73 | if clientConfig, ok := params.InitializationOptions.(map[string]any); ok { |
| 74 | if settings, ok := clientConfig["dockerfileExperimental"].(map[string]any); ok { |
| 75 | if value, ok := settings["removeOverlappingIssues"].(bool); ok { |
| 76 | buildkit.RemoveOverlappingIssues = value |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if settings, ok := clientConfig["dockercomposeExperimental"].(map[string]any); ok { |
| 81 | if composeSupport, ok := settings["composeSupport"].(bool); ok { |
| 82 | s.composeSupport = composeSupport |
| 83 | } |
| 84 | if composeCompletion, ok := settings["composeCompletion"].(bool); ok { |
| 85 | s.composeCompletion = s.composeSupport && composeCompletion |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if value, ok := clientConfig["telemetry"].(string); ok { |
| 90 | s.updateTelemetrySetting(value) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | if len(workspaceFolders) > 0 { |
| 95 | s.workspaceFolders = workspaceFolders |
| 96 | } else if params.RootURI != nil { |