From 5049160990deda5c64c48f55f864c051c36bb200 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 1 Mar 2026 22:27:56 +0100 Subject: [PATCH] add window features structs and types --- capabilities_client.go | 25 +++++++++++- progress.go | 25 ++++++++++++ window.go | 92 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 window.go diff --git a/capabilities_client.go b/capabilities_client.go index 51e0ea7..03b4f32 100644 --- a/capabilities_client.go +++ b/capabilities_client.go @@ -1,5 +1,28 @@ package protocol +// ShowDocumentClientCapabilities - Client capabilities for the show document request. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#showDocumentClientCapabilities +// +// @since 3.16.0 +type ShowDocumentClientCapabilities struct { + // The client has support for the show document request. + Support bool `json:"support"` +} + +// WindowClientCapabilities - Client capabilities for window features. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#windowClientCapabilities +type WindowClientCapabilities struct { + // It indicates whether the client supports the `window/showDocument` request. + // + // @since 3.16.0 + ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` +} + // ClientCapabilities defines the capabilities of the client (e.g., editor or IDE). // It tells the language server what features the client supports. -type ClientCapabilities struct{} +type ClientCapabilities struct { + // Window specific client capabilities. + Window *WindowClientCapabilities `json:"window,omitempty"` +} diff --git a/progress.go b/progress.go index ab42abc..3b96e51 100644 --- a/progress.go +++ b/progress.go @@ -2,6 +2,11 @@ package protocol import "encoding/json" +const ( + MethodWindowWorkDoneProgressCreate = "window/workDoneProgress/create" + MethodWindowWorkDoneProgressCancel = "window/workDoneProgress/cancel" +) + // ProgressToken - A token that can be used to report work done progress. // Can be a string or a number. // @@ -39,3 +44,23 @@ type PartialResultParams struct { // PartialResultToken is a token for handling partial result updates. PartialResultToken *ProgressToken `json:"partialResultToken,omitempty"` } + +// WorkDoneProgressCreateParams - The parameters of a work done progress create request. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workDoneProgressCreateParams +// +// @since 3.15.0 +type WorkDoneProgressCreateParams struct { + // The token to be used to report progress. + Token ProgressToken `json:"token"` +} + +// WorkDoneProgressCancelParams - The parameters of a work done progress cancel notification. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workDoneProgressCancelParams +// +// @since 3.15.0 +type WorkDoneProgressCancelParams struct { + // The token to be used to report progress. + Token ProgressToken `json:"token"` +} diff --git a/window.go b/window.go new file mode 100644 index 0000000..622d706 --- /dev/null +++ b/window.go @@ -0,0 +1,92 @@ +package protocol + +const ( + MethodWindowLogMessage = "window/logMessage" + MethodWindowShowMessage = "window/showMessage" + MethodWindowShowMessageRequest = "window/showMessageRequest" + MethodWindowShowDocument = "window/showDocument" +) + +// ShowMessageParams - The parameters of a show message notification. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#showMessageParams +type ShowMessageParams struct { + // The message type. See `MessageType`. + Type MessageType `json:"type"` + + // The actual message. + Message string `json:"message"` +} + +// ShowMessageRequestParams - The parameters of a show message request. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#showMessageRequestParams +type ShowMessageRequestParams struct { + ShowMessageParams + + // The message action items to present. + Actions []MessageActionItem `json:"actions,omitempty"` +} + +// MessageActionItem - A response item for a show message request. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#messageActionItem +type MessageActionItem struct { + // A short title like 'Retry', 'Open Log' etc. + Title string `json:"title"` +} + +// LogMessageParams - The parameters of a log message notification. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#logMessageParams +type LogMessageParams struct { + ShowMessageParams +} + +// ShowDocumentParams - Parameters for a show document request. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#showDocumentParams +// +// @since 3.16.0 +type ShowDocumentParams struct { + // The URI to show. + URI DocumentURI `json:"uri"` + + // Indicates if the editor should take focus. + TakeFocus *bool `json:"takeFocus,omitempty"` + + // Indicates if the URI should be opened in an external program. + External *bool `json:"external,omitempty"` + + // An optional selection range if the document is a text document. + Selection *Range `json:"selection,omitempty"` +} + +// ShowDocumentResult - Result of a show document request. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#showDocumentResult +// +// @since 3.16.0 +type ShowDocumentResult struct { + // Indicates whether the document was shown. + Success bool `json:"success"` +} + +// MessageType - The message type. +// +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#messageType +type MessageType int + +const ( + // An error message. + MessageTypeError MessageType = 1 + + // A warning message. + MessageTypeWarning MessageType = 2 + + // An information message. + MessageTypeInfo MessageType = 3 + + // A log message. + MessageTypeLog MessageType = 4 +)