### Complete Go LSP Server Example Source: https://context7.com/modern-dev/go-lsp/llms.txt A comprehensive Go example demonstrating the setup of a Language Server Protocol (LSP) server. It includes bidirectional communication logic suitable for testing via net.Pipe or for production environments using stdio. ```go package main import ( "context" "fmt" "net" "os" "github.com/modern-dev/go-lsp/protocol" "go.lsp.dev/jsonrpc2" ) type completeServer struct { client protocol.Client documents map[protocol.DocumentURI]string } func newCompleteServer() *completeServer { return &completeServer{documents: make(map[protocol.DocumentURI]string)} } func (s *completeServer) Initialize(ctx context.Context, params *protocol.InitializeParams) (*protocol.InitializeResult, error) { return &protocol.InitializeResult{ Capabilities: protocol.ServerCapabilities{ TextDocumentSync: &protocol.TextDocumentSyncOptions{ OpenClose: new(true), Change: new(protocol.TextDocumentSyncKindFull), Save: &protocol.SaveOptions{IncludeText: new(true)}, }, HoverProvider: true, CompletionProvider: &protocol.CompletionOptions{TriggerCharacters: []string{".", ":"}}, DefinitionProvider: true, ReferencesProvider: true, DocumentSymbolProvider: true, WorkspaceSymbolProvider: true, CodeActionProvider: true, RenameProvider: &protocol.RenameOptions{PrepareProvider: new(true)}, }, ServerInfo: &protocol.ServerInfo{Name: "complete-server", Version: new("1.0.0")}, }, nil } func (s *completeServer) Initialized(ctx context.Context, params *protocol.InitializedParams) error { // Server can now send requests to client if s.client != nil { _ = s.client.LogMessage(ctx, &protocol.LogMessageParams{ Type: protocol.MessageTypeInfo, Message: "Server initialized successfully", }) } return nil } func (s *completeServer) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error { s.documents[params.TextDocument.URI] = params.TextDocument.Text // Analyze and publish diagnostics if s.client != nil { _ = s.client.PublishDiagnostics(ctx, &protocol.PublishDiagnosticsParams{ URI: params.TextDocument.URI, Diagnostics: []protocol.Diagnostic{}, // Empty = no errors }) } return nil } // For stdio communication (production) func runStdio() { server := newCompleteServer() handler := protocol.ServerHandler(server, nil) stream := jsonrpc2.NewStream(os.Stdin, os.Stdout) conn := jsonrpc2.NewConn(stream) // Set up client dispatcher for server-to-client messages server.client = protocol.ClientDispatcher(conn, nil) conn.Go(context.Background(), handler) <-conn.Done() } // For testing with net.Pipe func runTest() { server := newCompleteServer() handler := protocol.ServerHandler(server, nil) clientConn, serverConn := net.Pipe() serverStream := jsonrpc2.NewStream(serverConn) sConn := jsonrpc2.NewConn(serverStream) server.client = protocol.ClientDispatcher(sConn, nil) sConn.Go(context.Background(), handler) clientStream := jsonrpc2.NewStream(clientConn) cConn := jsonrpc2.NewConn(clientStream) cConn.Go(context.Background(), jsonrpc2.MethodNotFoundHandler) // Client can now send requests ctx := context.Background() var result protocol.InitializeResult _, _ = cConn.Call(ctx, "initialize", protocol.InitializeParams{ ProcessId: new(int32), RootURI: "file:///workspace", Capabilities: protocol.ClientCapabilities{}, }, &result) fmt.Printf("Server: %s v%s\n", result.ServerInfo.Name, *result.ServerInfo.Version) // Cleanup _ = cConn.Close() _ = sConn.Close() } ``` -------------------------------- ### Install go-lsp dependency Source: https://github.com/modern-dev/go-lsp/blob/main/README.md Use the go get command to add the library to your Go project. ```bash go get github.com/modern-dev/go-lsp@latest ``` -------------------------------- ### Implement LSP Server in Go Source: https://github.com/modern-dev/go-lsp/blob/main/README.md Shows how to implement the Server interface and initialize a connection using the ServerHandler. This example demonstrates handling Initialize and Hover requests. ```go package main import ( "context" "os" "github.com/modern-dev/go-lsp/protocol" "go.lsp.dev/jsonrpc2" ) type myServer struct {} func (s *myServer) Initialize(ctx context.Context, params *protocol.InitializeParams) (*protocol.InitializeResult, error) { return &protocol.InitializeResult{ Capabilities: protocol.ServerCapabilities{ HoverProvider: true, }, ServerInfo: &protocol.ServerInfo{Name: "my-server"}, }, nil } func (s *myServer) Hover(ctx context.Context, params *protocol.HoverParams) (*protocol.Hover, error) { return &protocol.Hover{ Contents: protocol.MarkupContent{ Kind: protocol.MarkupKindMarkdown, Value: "Hello from **my-server**!", }, }, nil } func main() { server := &myServer{} handler := protocol.ServerHandler(server, nil) stream := jsonrpc2.NewStream(os.Stdin, os.Stdout) conn := jsonrpc2.NewConn(stream) conn.Go(context.Background(), handler) <-conn.Done() } ``` -------------------------------- ### Implement LSP Server with ServerHandler Source: https://context7.com/modern-dev/go-lsp/llms.txt Demonstrates how to implement the Server interface and use ServerHandler to dispatch JSON-RPC requests. This setup connects the server to standard input/output for communication with an LSP client. ```go package main import ( "context" "os" "github.com/modern-dev/go-lsp/protocol" "go.lsp.dev/jsonrpc2" ) type myServer struct{} func (s *myServer) Initialize(ctx context.Context, params *protocol.InitializeParams) (*protocol.InitializeResult, error) { return &protocol.InitializeResult{ Capabilities: protocol.ServerCapabilities{ HoverProvider: true, DefinitionProvider: true, CompletionProvider: &protocol.CompletionOptions{}, TextDocumentSync: &protocol.TextDocumentSyncOptions{ OpenClose: new(true), Change: new(protocol.TextDocumentSyncKindFull), }, }, ServerInfo: &protocol.ServerInfo{Name: "my-server", Version: new("1.0.0")}, }, nil } func main() { server := &myServer{} handler := protocol.ServerHandler(server, nil) stream := jsonrpc2.NewStream(os.Stdin, os.Stdout) conn := jsonrpc2.NewConn(stream) conn.Go(context.Background(), handler) <-conn.Done() } ``` -------------------------------- ### Implement Logger Interface for LSP in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Shows how to use the `Logger` interface for leveled logging within the protocol package. It includes an example of disabling logging with `NopLogger` and implementing a custom logger compatible with zap-style logging without requiring the zap dependency. ```go package main import ( "fmt" "github.com/modern-dev/go-lsp/protocol" ) // Custom logger implementation type customLogger struct{} func (l *customLogger) Debug(msg string, fields ...any) { fmt.Printf("[DEBUG] %s %v\n", msg, fields) } func (l *customLogger) Info(msg string, fields ...any) { fmt.Printf("[INFO] %s %v\n", msg, fields) } func (l *customLogger) Warn(msg string, fields ...any) { fmt.Printf("[WARN] %s %v\n", msg, fields) } func (l *customLogger) Error(msg string, fields ...any) { fmt.Printf("[ERROR] %s %v\n", msg, fields) } func loggerExample() { // Use NopLogger to disable all logging nopLogger := protocol.NopLogger() handler := protocol.ServerHandler(&myServer{}, nopLogger) // Use custom logger for debugging customLog := &customLogger{} handlerWithLogging := protocol.ServerHandler(&myServer{}, customLog) _, _ = handler, handlerWithLogging } type myServer struct{} // ... implement Server interface ... ``` -------------------------------- ### Implement LSP Server Interface in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Demonstrates how to implement the Server interface to handle lifecycle events and document operations. It shows initialization, document tracking, and hover request handling. ```go package main import ( "context" "fmt" "github.com/modern-dev/go-lsp/protocol" ) type languageServer struct { documents map[protocol.DocumentURI]string } func newLanguageServer() *languageServer { return &languageServer{documents: make(map[protocol.DocumentURI]string)} } func (s *languageServer) Initialize(ctx context.Context, params *protocol.InitializeParams) (*protocol.InitializeResult, error) { return &protocol.InitializeResult{ Capabilities: protocol.ServerCapabilities{ HoverProvider: true, DefinitionProvider: true, DocumentSymbolProvider: true, CompletionProvider: &protocol.CompletionOptions{TriggerCharacters: []string{"."}}, }, ServerInfo: &protocol.ServerInfo{Name: "example-lsp"}, }, nil } func (s *languageServer) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error { s.documents[params.TextDocument.URI] = params.TextDocument.Text return nil } func (s *languageServer) Hover(ctx context.Context, params *protocol.HoverParams) (*protocol.Hover, error) { text, ok := s.documents[params.TextDocument.URI] if !ok { return nil, nil } return &protocol.Hover{ Contents: protocol.MarkupContent{ Kind: protocol.MarkupKindMarkdown, Value: fmt.Sprintf("**Line %d, Character %d**\n\n```\n%s\n```", params.Position.Line, params.Position.Character, text), }, }, nil } ``` -------------------------------- ### Migrate to go-lsp/protocol Compatibility Layer in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Demonstrates how to use the compatibility layer for seamless migration from 'go.lsp.dev/protocol'. By changing the import path to 'github.com/modern-dev/go-lsp/protocol', existing code continues to work due to type and constant aliases. This includes aliases for server capabilities, markup kinds, code action kinds, and folding range kinds. ```go package main import ( // Change this import: // "go.lsp.dev/protocol" // To this: "github.com/modern-dev/go-lsp/protocol" ) func compatibilityExample() { // Type aliases work the same var wsCapabilities protocol.ServerCapabilitiesWorkspace var folderCaps protocol.ServerCapabilitiesWorkspaceFolders var fileOps protocol.ServerCapabilitiesWorkspaceFileOperations // Short-form constants are available _ = protocol.PlainText // alias for protocol.MarkupKindPlainText _ = protocol.Markdown // alias for protocol.MarkupKindMarkdown // Code action kinds _ = protocol.QuickFix // alias for protocol.CodeActionKindQuickFix _ = protocol.SourceOrganizeImports // alias for protocol.CodeActionKindSourceOrganizeImports // Folding range kinds _ = protocol.CommentFoldingRange // alias for protocol.FoldingRangeKindComment _ = protocol.ImportsFoldingRange // alias for protocol.FoldingRangeKindImports _ = protocol.RegionFoldingRange // alias for protocol.FoldingRangeKindRegion // ContentChangeEvent for incremental document changes change := protocol.ContentChangeEvent{ Range: &protocol.Range{ Start: protocol.Position{Line: 5, Character: 0}, End: protocol.Position{Line: 5, Character: 10}, }, RangeLength: 10, Text: "new text", } _, _, _, _ = wsCapabilities, folderCaps, fileOps, change } ``` -------------------------------- ### Initialize Semantic Token Provider in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Implements the Initialize method for a semantic token provider in Go. It configures the server capabilities, including the legend for semantic token types and modifiers, and enables full and range semantic token requests. Dependencies include the 'context' package and the 'github.com/modern-dev/go-lsp/protocol' package. ```go package main import ( "context" "github.com/modern-dev/go-lsp/protocol" ) type semanticServer struct{} func (s *semanticServer) Initialize(ctx context.Context, params *protocol.InitializeParams) (*protocol.InitializeResult, error) { return &protocol.InitializeResult{ Capabilities: protocol.ServerCapabilities{ SemanticTokensProvider: &protocol.SemanticTokensOptions{ Legend: protocol.SemanticTokensLegend{ TokenTypes: []string{ string(protocol.SemanticTokenNamespace), // compat alias string(protocol.SemanticTokenType), string(protocol.SemanticTokenClass), string(protocol.SemanticTokenFunction), string(protocol.SemanticTokenMethod), string(protocol.SemanticTokenVariable), string(protocol.SemanticTokenParameter), string(protocol.SemanticTokenKeyword), string(protocol.SemanticTokenString), string(protocol.SemanticTokenNumber), string(protocol.SemanticTokenComment), }, TokenModifiers: []string{ string(protocol.SemanticTokenModifierDeclaration), string(protocol.SemanticTokenModifierDefinition), string(protocol.SemanticTokenModifierReadonly), string(protocol.SemanticTokenModifierStatic), string(protocol.SemanticTokenModifierDeprecated), }, }, Full: new(true), Range: new(true), }, }, }, nil } ``` -------------------------------- ### Migrate import path Source: https://github.com/modern-dev/go-lsp/blob/main/README.md Demonstrates the diff for migrating from the deprecated go.lsp.dev/protocol package to the modern-dev/go-lsp package. ```diff - "go.lsp.dev/protocol" + "github.com/modern-dev/go-lsp/protocol" ``` -------------------------------- ### Convert File Path to Document URI in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Demonstrates the usage of `URIFromPath` to create a `DocumentURI` from a filesystem path. It handles platform-specific path separators and shows how to convert a URI back to a path and check if it's a file URI. ```go package main import ( "fmt" "github.com/modern-dev/go-lsp/protocol" ) func documentURIExample() { // Create URI from filesystem path (Unix) uri := protocol.URIFromPath("/home/user/project/main.go") fmt.Println(uri) // Output: file:///home/user/project/main.go // Create URI from filesystem path (Windows) windowsURI := protocol.URIFromPath("C:\\Users\\user\\project\\main.go") fmt.Println(windowsURI) // Output: file:///C:/Users/user/project/main.go // Convert URI back to filesystem path path := uri.Path() fmt.Println(path) // Output: /home/user/project/main.go // Check if URI is a file URI isFile := uri.IsFile() fmt.Println(isFile) // Output: true // Filename is an alias for Path filename := uri.Filename() fmt.Println(filename) // Output: /home/user/project/main.go } ``` -------------------------------- ### Dispatch Client Notifications in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Shows how to use the ClientDispatcher to send notifications such as diagnostics, messages, and logs from the server to the client over a JSON-RPC connection. ```go func serverWithClientNotifications() { clientConn, serverConn := net.Pipe() serverStream := jsonrpc2.NewStream(serverConn) sConn := jsonrpc2.NewConn(serverStream) client := protocol.ClientDispatcher(sConn, nil) ctx := context.Background() err := client.PublishDiagnostics(ctx, &protocol.PublishDiagnosticsParams{ URI: "file:///workspace/main.go", Diagnostics: []protocol.Diagnostic{ { Range: protocol.Range{ Start: protocol.Position{Line: 10, Character: 0}, End: protocol.Position{Line: 10, Character: 15}, }, Message: "undefined: someVariable", }, }, }) err = client.ShowMessage(ctx, &protocol.ShowMessageParams{ Type: protocol.MessageTypeInfo, Message: "Language server initialized successfully", }) } ``` -------------------------------- ### Implement Completion Method in Go LSP Source: https://context7.com/modern-dev/go-lsp/llms.txt This implementation of the Completion method extracts the current line of text from the document, filters a predefined set of completion items based on the user's input prefix, and returns a CompletionList. It utilizes the protocol package to define completion items with labels, kinds, and snippet-based insert text. ```go func (s *completionServer) Completion(ctx context.Context, params *protocol.CompletionParams) (any, error) { text, ok := s.documents[params.TextDocument.URI] if !ok { return nil, nil } // Get the line being edited lines := strings.Split(text, "\n") if int(params.Position.Line) >= len(lines) { return nil, nil } line := lines[params.Position.Line] prefix := line[:params.Position.Character] // Build completion items based on context items := []protocol.CompletionItem{ { Label: "fmt.Println", Kind: new(protocol.CompletionItemKindFunction), Detail: new("func(a ...any) (n int, err error)"), Documentation: "Println formats using default formats and writes to standard output.", InsertText: new("fmt.Println($0)"), InsertTextFormat: new(protocol.InsertTextFormatSnippet), }, { Label: "for", Kind: new(protocol.CompletionItemKindKeyword), Detail: new("for loop"), InsertText: new("for ${1:i} := ${2:0}; $1 < ${3:n}; $1++ {\n\t$0\n}"), InsertTextFormat: new(protocol.InsertTextFormatSnippet), }, { Label: "func", Kind: new(protocol.CompletionItemKindKeyword), Detail: new("function declaration"), InsertText: new("func ${1:name}(${2:params}) ${3:returnType} {\n\t$0\n}"), InsertTextFormat: new(protocol.InsertTextFormatSnippet), }, } // Filter based on prefix var filtered []protocol.CompletionItem for _, item := range items { if strings.HasPrefix(strings.ToLower(item.Label), strings.ToLower(strings.TrimSpace(prefix))) { filtered = append(filtered, item) } } return &protocol.CompletionList{ IsIncomplete: false, Items: filtered, }, nil } ``` -------------------------------- ### Run code generation Source: https://github.com/modern-dev/go-lsp/blob/main/README.md Commands to trigger the code generator to update types from the LSP specification. ```bash # Re-generate from the default spec ref go generate ./protocol/... # Or run the generator directly go run ./cmd/generate -o ./protocol ``` -------------------------------- ### Implement DocumentSymbol for Go LSP Source: https://context7.com/modern-dev/go-lsp/llms.txt This Go code snippet demonstrates the implementation of the `DocumentSymbol` method. It takes context and document symbol parameters and returns hierarchical document symbols, including functions, variables, structs, and fields. This functionality is essential for features like 'Go to Symbol' in IDEs. ```go package main import ( "context" "github.com/modern-dev/go-lsp/protocol" ) type symbolServer struct{} func (s *symbolServer) DocumentSymbol(ctx context.Context, params *protocol.DocumentSymbolParams) (any, error) { // Return hierarchical document symbols symbols := []protocol.DocumentSymbol{ { Name: "main", Kind: protocol.SymbolKindFunction, Detail: new("func()") , Range: protocol.Range{ Start: protocol.Position{Line: 5, Character: 0}, End: protocol.Position{Line: 15, Character: 1}, }, SelectionRange: protocol.Range{ Start: protocol.Position{Line: 5, Character: 5}, End: protocol.Position{Line: 5, Character: 9}, }, Children: []protocol.DocumentSymbol{ { Name: "server", Kind: protocol.SymbolKindVariable, Range: protocol.Range{ Start: protocol.Position{Line: 6, Character: 1}, End: protocol.Position{Line: 6, Character: 30}, }, SelectionRange: protocol.Range{ Start: protocol.Position{Line: 6, Character: 1}, End: protocol.Position{Line: 6, Character: 7}, }, }, }, }, { Name: "MyStruct", Kind: protocol.SymbolKindStruct, Detail: new("type") , Range: protocol.Range{ Start: protocol.Position{Line: 17, Character: 0}, End: protocol.Position{Line: 22, Character: 1}, }, SelectionRange: protocol.Range{ Start: protocol.Position{Line: 17, Character: 5}, End: protocol.Position{Line: 17, Character: 13}, }, Children: []protocol.DocumentSymbol{ { Name: "Name", Kind: protocol.SymbolKindField, Range: protocol.Range{ Start: protocol.Position{Line: 18, Character: 1}, End: protocol.Position{Line: 18, Character: 12}, }, SelectionRange: protocol.Range{ Start: protocol.Position{Line: 18, Character: 1}, End: protocol.Position{Line: 18, Character: 5}, }, }, }, }, } return symbols, nil } ``` -------------------------------- ### Update LSP Version using go run Source: https://context7.com/modern-dev/go-lsp/llms.txt This command updates the LSP protocol definitions by running a Go script. It takes a Git reference for the protocol version and an output directory for the generated files. The `-model` flag can optionally specify a local metaModel.json file. ```bash go run ./cmd/generate -ref release/protocol/3.18.0 -o ./protocol ``` -------------------------------- ### LSP Server Interface Source: https://context7.com/modern-dev/go-lsp/llms.txt The Server interface defines the core LSP methods for handling lifecycle, document synchronization, and language features. ```APIDOC ## [LSP] Initialize ### Description Initializes the language server, defining capabilities and server information. ### Method RPC/Method Call ### Endpoint initialize ### Parameters #### Request Body - **params** (InitializeParams) - Required - The initialization parameters including capabilities and root URI. ### Request Example { "processId": 1234, "rootUri": "file:///workspace" } ### Response #### Success Response (200) - **capabilities** (ServerCapabilities) - The capabilities the server provides. - **serverInfo** (ServerInfo) - Information about the server. #### Response Example { "capabilities": { "hoverProvider": true, "definitionProvider": true }, "serverInfo": { "name": "example-lsp" } } ``` -------------------------------- ### Utilize LSP Error Codes for Server Responses in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Illustrates the use of standard LSP error codes, which extend JSON-RPC error codes, for returning errors from server methods. This ensures proper error semantics are communicated to clients, covering scenarios like server initialization status and request cancellation. ```go package main import ( "context" "fmt" "github.com/modern-dev/go-lsp/protocol" ) // LSP Error Codes: // protocol.CodeServerNotInitialized (-32002) - Request before initialize // protocol.CodeInvalidRequest (-32600) - Invalid request in current state // protocol.CodeMethodNotFound (-32601) - Method not supported // protocol.CodeInvalidParams (-32602) - Invalid parameters // protocol.CodeInternalError (-32603) - Internal server error // protocol.CodeParseError (-32700) - JSON parsing failed // protocol.CodeRequestCancelled (-32800) - Client cancelled request // protocol.CodeContentModified (-32801) - Content modified during request type serverWithErrorHandling struct { initialized bool } func (s *serverWithErrorHandling) Definition(ctx context.Context, params *protocol.DefinitionParams) (any, error) { if !s.initialized { return nil, fmt.Errorf("server not initialized (code: %d)", protocol.CodeServerNotInitialized) } // Check for cancelled context select { case <-ctx.Done(): return nil, fmt.Errorf("request cancelled (code: %d)", protocol.CodeRequestCancelled) default: } // Return definition location return &protocol.Location{ URI: params.TextDocument.URI, Range: protocol.Range{ Start: protocol.Position{Line: 0, Character: 0}, End: protocol.Position{Line: 0, Character: 10}, }, }, nil } ``` -------------------------------- ### Generate LSP Protocol Code in Bash Source: https://context7.com/modern-dev/go-lsp/llms.txt Commands to regenerate Go source files for the LSP protocol using the code generator. It reads Microsoft's 'metaModel.json' specification to produce 'types_gen.go', 'server_gen.go', and 'client_gen.go'. This allows updating to new LSP versions or customizing generated code. ```bash # Re-generate from the default spec ref (LSP 3.17) go generate ./protocol/... # Run the generator directly go run ./cmd/generate -o ./protocol # Use a local metaModel.json file go run ./cmd/generate -o ./protocol -model ./path/to/metaModel.json ``` -------------------------------- ### Provide Full Semantic Tokens in Go Source: https://context7.com/modern-dev/go-lsp/llms.txt Implements the SemanticTokensFull method to return encoded semantic tokens for a given context and parameters. Each token is represented by five integers: deltaLine, deltaStartChar, length, tokenType, and tokenModifiers. This function is crucial for rich syntax highlighting in LSP clients. ```go func (s *semanticServer) SemanticTokensFull(ctx context.Context, params *protocol.SemanticTokensParams) (*protocol.SemanticTokens, error) { // Return encoded semantic tokens // Each token is encoded as 5 integers: deltaLine, deltaStartChar, length, tokenType, tokenModifiers return &protocol.SemanticTokens{ Data: []uint32{ 0, 0, 7, 7, 0, // "package" keyword at line 0, char 0, length 7, type=keyword(7) 0, 8, 4, 0, 1, // "main" namespace at line 0, char 8, length 4, type=namespace(0), modifier=declaration(1) 2, 0, 4, 7, 0, // "func" keyword at line 2, char 0 0, 5, 4, 3, 1, // "main" function at line 2, char 5, type=function(3), modifier=declaration }, }, nil } ``` -------------------------------- ### ClientDispatcher Notifications Source: https://context7.com/modern-dev/go-lsp/llms.txt The ClientDispatcher allows the server to send notifications and requests back to the client, such as diagnostic updates or status messages. ```APIDOC ## [LSP] PublishDiagnostics ### Description Sends diagnostic information (errors, warnings) to the client for a specific file. ### Method RPC/Notification ### Endpoint textDocument/publishDiagnostics ### Parameters #### Request Body - **uri** (DocumentURI) - Required - The URI of the document. - **diagnostics** (Diagnostic[]) - Required - The list of diagnostics to report. ### Request Example { "uri": "file:///workspace/main.go", "diagnostics": [{ "range": { "start": { "line": 10 }, "end": { "line": 10 } }, "message": "undefined variable" }] } ### Response #### Success Response (200) - None (Notification only) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.