Documentation ¶
Overview ¶
Package lsp provides a set of types and functions for working with the LSP protocol. It includes types for LSP messages, notifications, requests, and responses.
The types in this package are used to represent LSP messages, notifications, requests, and responses.
Index ¶
- type CancelParams
- type CancelRequest
- type CancelResponse
- type ClientCapabilities
- type ClientInfo
- type CodeAction
- type CodeActionContext
- type CodeActionRequest
- type Command
- type CompletionItem
- type CompletionItemKind
- type CompletionItemTag
- type CompletionParams
- type CompletionRequest
- type CompletionResponse
- type Diagnostic
- type DiagnosticSeverity
- type DidChangeTextDocumentParams
- type DidCloseTextDocumentParamsNotification
- type DidCloseTextDocumentParamsNotificationParams
- type DidOpenTextDocumentNotification
- type DidOpenTextDocumentParams
- type HoverParams
- type HoverRequest
- type HoverResponse
- type HoverResult
- type InitializeRequest
- type InitializeRequestParams
- type InitializeResponse
- type InitializeResult
- type InitializedParamsRequest
- type Location
- type Notification
- type Position
- type PublishDiagnosticsNotification
- type PublishDiagnosticsParams
- type Range
- type Request
- type Response
- type Server
- type ServerCapabilities
- type ServerInfo
- type ShutdownRequest
- type ShutdownResponse
- type TextDocumentCodeActionParams
- type TextDocumentCodeActionResponse
- type TextDocumentContentChangeEvent
- type TextDocumentDidChangeNotification
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentPositionParams
- type TextEdit
- type VersionTextDocumentIdentifier
- type WorkspaceEdit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancelParams ¶
type CancelParams struct { // ID is the id of the request to be cancelled. ID string `json:"id"` }
CancelParams are the parameters for a cancel request.
type CancelRequest ¶
type CancelRequest struct { // CancelRequest embeds the Request struct Request // ID is the id of the request to be cancelled. ID string `json:"id"` // Params are the parameters for the request to be cancelled. Params CancelParams `json:"params"` }
CancelRequest is sent from the client to the server to cancel a request.
type CancelResponse ¶
type CancelResponse struct { // CancelResponse embeds the Response struct Response }
CancelResponse is the response for a cancel request.
type ClientCapabilities ¶
type ClientCapabilities struct { // TextDocumentSync is the text document sync for the client capabilities. TextDocumentSync int `json:"textDocumentSync"` // HoverProvider is a boolean indicating whether the server provides. HoverProvider bool `json:"hoverProvider"` // DefinitionProvider is a boolean indicating whether the server provides definition capabilities. DefinitionProvider bool `json:"definitionProvider"` // CodeActionProvider is a boolean indicating whether the server provides code actions. CodeActionProvider bool `json:"codeActionProvider"` // CompletionProvider is a map of completion providers. CompletionProvider map[string]any `json:"completionProvider"` }
ClientCapabilities is a struct for the client capabilities
type ClientInfo ¶
type ClientInfo struct { // Name is the name of the client Name string `json:"name"` // Version is the version of the client Version string `json:"version"` }
ClientInfo is a struct for the client info
type CodeAction ¶
type CodeAction struct { // Title is the title for the code action. Title string `json:"title"` // Edit is the edit for the code action. Edit *WorkspaceEdit `json:"edit,omitempty"` // Command is the command for the code action. Command *Command `json:"command,omitempty"` }
CodeAction is a code action for a given text document.
type CodeActionContext ¶
type CodeActionContext struct { }
CodeActionContext is the context for a code action request.
type CodeActionRequest ¶
type CodeActionRequest struct { // CodeActionRequest embeds the Request struct Request // Params are the parameters for the code action request. Params TextDocumentCodeActionParams `json:"params"` }
CodeActionRequest is a request for a code action to the language server.
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_code
type Command ¶
type Command struct { // Title is the title for the command. Title string `json:"title"` // Command is the command for the command. Command string `json:"command"` // Arguments are the arguments for the command. Arguments []interface{} `json:"arguments,omitempty"` }
Command is a command for a given text document.
type CompletionItem ¶
type CompletionItem struct { // Label is the label for the completion item Label string `json:"label"` // Detail is the detail for the completion item Detail string `json:"detail"` // Documentation is the documentation for the completion item Documentation string `json:"documentation"` // Kind is the kind of the completion item Kind CompletionItemKind `json:"kind"` }
CompletionItem is a struct for a completion item
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
type CompletionItemKind ¶
type CompletionItemKind int
CompletionItemKind is an enum for completion item kinds.
const ( // Text is a completion item kind Text CompletionItemKind = iota + 1 // Method is a completion item kind for a method or function completion Method // Function is a completion item kind for a function completion Function // Constructor is a completion item kind for a constructor completion Constructor // Field is a completion item kind for a field completion Field // Variable is a completion item kind for a variable completion Variable // Class is a completion item kind for a class completion Class // Interface is a completion item kind for an interface completion Interface // Module is a completion item kind for a module completion Module // Property is a completion item kind for a property completion Property // Unit is a completion item kind for a unit Unit // Value is a completion item kind for a value Value // Enum is a completion item kind for an enum Enum // Keyword is a completion item kind for a keyword Keyword // Snippet is a completion item kind for a snippet Snippet // Color is a completion item kind for a color Color // File is a completion item kind for a file File // Reference is a completion item kind for a reference Reference // Folder is a completion item kind for a folder Folder // EnumMember is a completion item kind for an enum member EnumMember // Constant is a completion item kind for a constant Constant // Struct is a completion item kind for a struct Struct // Event is a completion item kind for an event Event // Operator is a completion item kind for an operator Operator // TypeParameter is a completion item kind for a type parameter TypeParameter )
func (CompletionItemKind) String ¶
func (c CompletionItemKind) String() string
String returns the string representation of the CompletionItemKind.
type CompletionItemTag ¶
type CompletionItemTag struct {
Deprecated bool `json:"deprecated"`
}
CompletionItemTag is a struct for a completion item tag
type CompletionParams ¶
type CompletionParams struct { // CompletionParams embeds the TextDocumentPositionParams struct TextDocumentPositionParams }
CompletionParams is a struct for the completion params
type CompletionRequest ¶
type CompletionRequest struct { // CompletionRequest embeds the Request struct Request // Params are the parameters for the completion request Params CompletionParams `json:"params"` }
CompletionRequest is a request for a completion to the language server
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
type CompletionResponse ¶
type CompletionResponse struct { // CompletionResponse embeds the Response struct Response // Result is the result of the completion request Result []CompletionItem `json:"result"` }
CompletionResponse is a response for a completion to the language server
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
type Diagnostic ¶
type Diagnostic struct { // Range is the range for the diagnostic. Range Range `json:"range"` // Severity is the severity for the diagnostic. Severity DiagnosticSeverity `json:"severity"` // Source is the source for the diagnostic. Source string `json:"source"` // Message is the message for the diagnostic. Message string `json:"message"` }
Diagnostic is a struct for a diagnostic.
type DiagnosticSeverity ¶
type DiagnosticSeverity int
DiagnosticSeverity is an enum for diagnostic severities.
const ( // DiagnosticError reports an error. DiagnosticError DiagnosticSeverity = iota + 1 // DiagnosticWarning reports a warning. DiagnosticWarning // DiagnosticInformation reports an information. DiagnosticInformation // DiagnosticHint reports a hint. DiagnosticHint )
func (DiagnosticSeverity) String ¶
func (d DiagnosticSeverity) String() string
String returns the string representation of the DiagnosticSeverity.
type DidChangeTextDocumentParams ¶
type DidChangeTextDocumentParams struct { // TextDocument is the document that did change. The version number points to the version TextDocument VersionTextDocumentIdentifier `json:"textDocument"` // ContentChanges is the array of content changes. ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` }
DidChangeTextDocumentParams is sent from the client to the server to signal that the content of a text document has changed.
type DidCloseTextDocumentParamsNotification ¶
type DidCloseTextDocumentParamsNotification struct { Notification Params DidCloseTextDocumentParamsNotificationParams `json:"params"` }
DidCloseTextDocumentParamsNotification is a struct for the did close text document params notification
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didClose
func NewDidCloseTextDocumentParamsNotification ¶
func NewDidCloseTextDocumentParamsNotification( uri string, ) DidCloseTextDocumentParamsNotification
NewDidCloseTextDocumentParamsNotification returns a new did close text document params notification
type DidCloseTextDocumentParamsNotificationParams ¶
type DidCloseTextDocumentParamsNotificationParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
DidCloseTextDocumentParamsNotificationParams is a struct for the did close text document params notification params
type DidOpenTextDocumentNotification ¶
type DidOpenTextDocumentNotification struct { // DidOpenTextDocumentNotification embeds the Notification struct Notification // Params are the parameters for the notification. Params DidOpenTextDocumentParams `json:"params"` }
DidOpenTextDocumentNotification is a notification that is sent when the client opens a text document.
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didOpen
type DidOpenTextDocumentParams ¶
type DidOpenTextDocumentParams struct { // TextDocument is the text document after it has been opened. TextDocument TextDocumentItem `json:"textDocument"` }
DidOpenTextDocumentParams contains the text document after it has been opened.
type HoverParams ¶
type HoverParams struct { // TextDocumentPositionParams is the text document position parameters. TextDocumentPositionParams }
HoverParams is the parameters for a hover request.
type HoverRequest ¶
type HoverRequest struct { // HoverRequest embeeds the request struct. Request // Params are the parameters for the hover request. Params HoverParams `json:"params"` }
HoverRequest is sent from the client to the server to request hover information.
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover
type HoverResponse ¶
type HoverResponse struct { // Response is the response for the hover request. Response // Result is the result for the hover request. Result HoverResult `json:"result"` }
HoverResponse is the response from the server to a hover request.
type HoverResult ¶
type HoverResult struct { // Contents is the contents for the hover result. Contents string `json:"contents"` }
HoverResult is a result from a hover request to the client from the language server.
type InitializeRequest ¶
type InitializeRequest struct { // InitializeRequest embeds the Request struct Request // Params are the parameters for the initialize request. Params InitializeRequestParams `json:"params"` }
InitializeRequest is a struct for the initialize request.
type InitializeRequestParams ¶
type InitializeRequestParams struct { // ClientInfo is the client info of the client in the request ClientInfo *ClientInfo `json:"clientInfo"` // InitializationOptions is the initialization options of the client in the request RootPath string `json:"rootPath,omitempty"` // Trace is the trace of the client in the request Trace string `json:"trace,omitempty"` }
InitializeRequestParams is a struct for the initialize request params
type InitializeResponse ¶
type InitializeResponse struct { Response // Result is the result of the initialize request Result InitializeResult `json:"result"` }
InitializeResponse is a struct for the initialize response.
It embeds the Response struct.
func NewInitializeResponse ¶
func NewInitializeResponse(id int) InitializeResponse
NewInitializeResponse creates a new initialize response.
type InitializeResult ¶
type InitializeResult struct { // Capabilities are the capabilities of the server for the initialize response. Capabilities ServerCapabilities `json:"capabilities"` // ServerInfo is the server info for the initialize response. ServerInfo ServerInfo `json:"serverInfo"` }
InitializeResult is a struct for the initialize result used in the initialize response.
type InitializedParamsRequest ¶
type InitializedParamsRequest struct { // InitializedParamsRequest embeds the Request struct Response }
InitializedParamsRequest is a struct for the initialized params.
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialized
type Location ¶
type Location struct { // URI is the uri for the location. URI string `json:"uri"` // Range is the range for the location. Range Range `json:"range"` }
Location is a location inside a resource, such as a line inside a text file.
type Notification ¶
type Notification struct { // RPC is the rpc method for the notification. RPC string `json:"jsonrpc"` // Method is the method for the notification. Method string `json:"method"` }
Notification is a notification from a LSP
type Position ¶
type Position struct { // Line is the line number for the position (zero-based). Line int `json:"line"` // Character is the character number for the position (zero-based). Character int `json:"character"` }
Position is a position inside a text document.
type PublishDiagnosticsNotification ¶
type PublishDiagnosticsNotification struct { // PublishDiagnosticsNotification embeeds the notification struct. Notification // Params are the parameters for the publish diagnostics notification. Params PublishDiagnosticsParams `json:"params"` }
PublishDiagnosticsNotification is the notification for publishing diagnostics.
type PublishDiagnosticsParams ¶
type PublishDiagnosticsParams struct { // URI is the uri for the diagnostics. URI string `json:"uri"` // Diagnostics are the diagnostics for the uri. Diagnostics []Diagnostic `json:"diagnostics"` }
PublishDiagnosticsParams are the parameters for the publish diagnostics notification.
type Range ¶
type Range struct { // Start is the start of a given range. Start Position `json:"start"` // End is the end of a given range. End Position `json:"end"` }
Range is a range in a text document.
type Request ¶
type Request struct { // RPC is the rpc method for the request RPC string `json:"jsonrpc"` // ID is the id of the request ID int `json:"id,omitempty"` // Method is the method for the request Method string `json:"method"` }
Request is the request to a LSP
type Response ¶
type Response struct { // RPC is the rpc method for the response RPC string `json:"jsonrpc"` // ID is the id of the response ID int `json:"id,omitempty"` }
Response is the response of a LSP
type Server ¶
type Server interface { // bun.QueryHook is an embedded interface within the Server interface bun.QueryHook // HandleMessage handles a message from the client HandleMessage(msg []byte) error // ReturnCmd returns the command for starting the LSP server ReturnCmd() *cobra.Command }
Server is a struct for the LSP server
type ServerCapabilities ¶
type ServerCapabilities struct { // TextDocumentSync is what the server supports for syncing text documents. TextDocumentSync int `json:"textDocumentSync"` // HoverProvider is a boolean indicating whether the server provides. HoverProvider bool `json:"hoverProvider"` // DefinitionProvider is a boolean indicating whether the server provides definition capabilities. DefinitionProvider bool `json:"definitionProvider"` // CodeActionProvider is a boolean indicating whether the server provides code actions. CodeActionProvider bool `json:"codeActionProvider"` // CompletionProvider is a map of completion providers. CompletionProvider map[string]any `json:"completionProvider"` }
ServerCapabilities is a struct for the server capabilities
type ServerInfo ¶
type ServerInfo struct { // Name is the name of the server Name string `json:"name"` // Version is the version of the server Version string `json:"version"` }
ServerInfo is a struct for the server info.
type ShutdownRequest ¶
type ShutdownRequest struct {
Request
}
ShutdownRequest is the request
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#shutdown
type ShutdownResponse ¶
ShutdownResponse is the response to a ShutdownRequest. Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#shutdown
type TextDocumentCodeActionParams ¶
type TextDocumentCodeActionParams struct { // TextDocument is the text document for the code action request. TextDocument TextDocumentIdentifier `json:"textDocument"` // Range is the range for the code action request. Range Range `json:"range"` // Context is the context for the code action request. Context CodeActionContext `json:"context"` }
TextDocumentCodeActionParams are the parameters for a code action request.
type TextDocumentCodeActionResponse ¶
type TextDocumentCodeActionResponse struct { // TextDocumentCodeActionResponse embeds the Response struct Response // Result is the result for the code action request. Result []CodeAction `json:"result"` }
TextDocumentCodeActionResponse is the response for a code action request.
type TextDocumentContentChangeEvent ¶
type TextDocumentContentChangeEvent struct { // The new text of the whole document. Text string `json:"text"` }
TextDocumentContentChangeEvent is sent from the client to the server to signal that the content of a text document has changed.
type TextDocumentDidChangeNotification ¶
type TextDocumentDidChangeNotification struct { // TextDocumentDidChangeNotification embeds the Notification struct Notification // Params are the parameters for the notification. Params DidChangeTextDocumentParams `json:"params"` }
TextDocumentDidChangeNotification is sent from the client to the server to signal that the content of a text document has changed.
Microsoft LSP Docs: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didChange
type TextDocumentIdentifier ¶
type TextDocumentIdentifier struct { // URI is the uri for the text document. URI string `json:"uri"` }
TextDocumentIdentifier is a unique identifier for a text document.
type TextDocumentItem ¶
type TextDocumentItem struct { // URI is the uri for the text document. URI string `json:"uri"` // LanguageID is the language id for the text document. LanguageID string `json:"languageId"` // Version is the version number of a given text document. Version int `json:"version"` // Text is the text of the text document. Text string `json:"text"` }
TextDocumentItem is a text document.
type TextDocumentPositionParams ¶
type TextDocumentPositionParams struct { // TextDocument is the text document for the position parameters. TextDocument TextDocumentIdentifier `json:"textDocument"` // Position is the position for the text document. Position Position `json:"position"` }
TextDocumentPositionParams is a text document position parameters.
type TextEdit ¶
type TextEdit struct { // Range is the range for the text edit. Range Range `json:"range"` // NewText is the new text for the text edit. NewText string `json:"newText"` }
TextEdit represents an edit operation on a single text document.
type VersionTextDocumentIdentifier ¶
type VersionTextDocumentIdentifier struct { // VersionTextDocumentIdentifier embeds the TextDocumentIdentifier struct TextDocumentIdentifier // Version is the version number for the text document. Version int `json:"version"` }
VersionTextDocumentIdentifier is a text document with a version number.
type WorkspaceEdit ¶
type WorkspaceEdit struct { // Changes is the changes for the workspace edit. Changes map[string][]TextEdit `json:"changes"` }
WorkspaceEdit is the workspace edit object.