lsp

package
v0.6.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INITIALIZE             = "initialize"
	TD_DID_OPEN            = "textDocument/didOpen"
	TD_DID_CHANGE          = "textDocument/didChange"
	TD_COMPLETION          = "textDocument/completion"
	TD_CODE_ACTION         = "textDocument/codeAction"
	TD_PUBLISH_DIAGNOSTICS = "textDocument/publishDiagnostics"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type CodeAction

type CodeAction struct {
	Title   string         `json:"title"`
	Edit    *WorkspaceEdit `json:"edit,omitempty"`
	Command *Command       `json:"command,omitempty"`
}

func NewCodeActionEdit

func NewCodeActionEdit(title string, edit WorkspaceEdit) CodeAction

type CodeActionParams

type CodeActionParams struct {
	// The document in which the command was invoked.
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	// The range for which the command was invoked.
	Range Range `json:"range"`
}

type Command

type Command struct {
	Title     string        `json:"title"`
	Command   string        `json:"command"`
	Arguments []interface{} `json:"arguments,omitempty"`
}

type CompletionItem

type CompletionItem struct {
	/**
	 * The label of this completion item.
	 *
	 * The label property is also by default the text that
	 * is inserted when selecting this completion, UNLESS TEXTEDIT PROVIDED.
	 *
	 * If label details are provided the label itself should
	 * be an unqualified name of the completion item.
	 */
	Label    string    `json:"label"`
	Detail   string    `json:"detail"`
	Doc      string    `json:"documentation,omitempty"`
	TextEdit *TextEdit `json:"textEdit,omitempty"`
}

func NewCompletionItem

func NewCompletionItem(label, detail, doc string) CompletionItem

type CompletionParams

type CompletionParams struct {
	TextDocumentPositionParams
}

type Diagnostic

type Diagnostic struct {
	Range    Range              `json:"range"`
	Severity DiagnosticSeverity `json:"severity"`
	/**
	 * A human-readable string describing the source of this
	 * diagnostic, e.g. 'typescript' or 'super lint'.
	 */
	Source string `json:"source"`
	/** The diagnostic's message. */
	Message string `json:"message"`
}

func NewDiagnostic

func NewDiagnostic(rang Range, severity DiagnosticSeverity, source, msg string) Diagnostic

func NewDiagnosticFromCheck

func NewDiagnosticFromCheck(checkD check.Diagnostic) Diagnostic

type DiagnosticSeverity

type DiagnosticSeverity int
const (
	Err  DiagnosticSeverity = 1
	Warn DiagnosticSeverity = 2
	Info DiagnosticSeverity = 3
	Hint DiagnosticSeverity = 4
)

type DidChangeTextDocumentParams

type DidChangeTextDocumentParams struct {
	/**
	 * The document that did change. The version number points
	 * to the version after all provided content changes have
	 * been applied.
	 */
	TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`

	/**
	 * The actual content changes. The content changes describe single state
	 * changes to the document. So if there are two content changes c1 (at
	 * array index 0) and c2 (at array index 1) for a document in state S then
	 * c1 moves the document from S to S' and c2 from S' to S”. So c1 is
	 * computed on the state S and c2 is computed on the state S'.
	 *
	 * To mirror the content of a document using change events use the following
	 * approach:
	 * - start with the same initial content
	 * - apply the 'textDocument/didChange' notifications in the order you
	 *   receive them.
	 * - apply the `TextDocumentContentChangeEvent`s in a single notification
	 *   in the order you receive them.
	 */
	ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
}

type DidOpenTextDocumentParams

type DidOpenTextDocumentParams struct {
	/**
	 * The document that was opened.
	 */
	TextDocument TextDocumentItem `json:"textDocument"`
}

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#didOpenTextDocumentParams

type Error

type Error struct {
	Code int64 `json:"code"`
	// Should be limited to a single concise sentence.
	Msg  string `json:"message"`
	Data any    `json:"data,omitempty"`
}

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#responseError

type IncomingMsg

type IncomingMsg struct {
	Msg
	Id     *json.RawMessage `json:"id"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

func (IncomingMsg) AsNotification

func (m IncomingMsg) AsNotification() (Notification, bool)

func (IncomingMsg) AsRequest

func (m IncomingMsg) AsRequest() (Request, bool)

func (IncomingMsg) IsNotification

func (m IncomingMsg) IsNotification() bool

func (IncomingMsg) IsRequest

func (m IncomingMsg) IsRequest() bool

type InitializeParams

type InitializeParams struct {
	ClientInfo *ClientInfo `json:"clientInfo"`
}

type InitializeResult

type InitializeResult struct {
	Capabilities ServerCapabilities `json:"capabilities"`
	ServerInfo   ServerInfo         `json:"serverInfo"`
}

func NewInitializeResult

func NewInitializeResult() InitializeResult

type Location

type Location struct {
	Uri   string `json:"uri"`
	Range Range  `json:"range"`
}

type Msg

type Msg struct {
	Rpc string `json:"jsonrpc"` // probably always be 2.0
}

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#message

type Notification

type Notification struct {
	Msg
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage

func NewNotification

func NewNotification(method string, params *json.RawMessage) Notification

type Pos

type Pos struct {
	/** Zero-indexed */
	Line int `json:"line"`
	/** Zero-indexed */
	Character int `json:"character"`
}

func NewPos

func NewPos(line int, character int) Pos

type PublishDiagnosticsParams

type PublishDiagnosticsParams struct {
	Uri         string       `json:"uri"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

func NewPublishDiagnosticsParams

func NewPublishDiagnosticsParams(uri string, diagnostics []Diagnostic) PublishDiagnosticsParams

type Range

type Range struct {
	Start Pos `json:"start"`
	End   Pos `json:"end"`
}

func NewLineRange

func NewLineRange(line, start, end int) Range

func NewRange

func NewRange(startLine, starChar, endLine, endChar int) Range

func NewRangeFromCheckNode

func NewRangeFromCheckNode(rang check.Range) Range

func NewRangeFromTsNode

func NewRangeFromTsNode(node *ts.Node) Range

type Request

type Request struct {
	Msg
	Id     *json.RawMessage `json:"id"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage

type Response

type Response struct {
	Msg
	Id     *json.RawMessage `json:"id"`
	Result any              `json:"result"`
	Error  *Error           `json:"error,omitempty"`
}

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#responseMessage

func NewResponse

func NewResponse(id *json.RawMessage, result any) Response

func NewResponseError

func NewResponseError(id *json.RawMessage, err error) (resp Response)

type ServerCapabilities

type ServerCapabilities struct {
	TextDocumentSync int32 `json:"textDocumentSync"`
	//HoverProvider      bool           `json:"hoverProvider"`
	//DefinitionProvider bool           `json:"definitionProvider"`
	CodeActionProvider bool           `json:"codeActionProvider"`
	CompletionProvider map[string]any `json:"completionProvider"`
}

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type TextDocumentContentChangeEvent

type TextDocumentContentChangeEvent struct {
	/**
	 * The new text of the whole document.
	 */
	Text string `json:"text"`
}

*

  • An event describing a change to a text document. If only a text is provided
  • it is considered to be the full content of the document.

type TextDocumentIdentifier

type TextDocumentIdentifier struct {
	Uri string `json:"uri"`
}

type TextDocumentItem

type TextDocumentItem struct {
	/**
	 * The text document's URI.
	 */
	Uri string `json:"uri"`
	/**
	 * The text document's language identifier.
	 */
	LanguageId string `json:"languageId"`
	/**
	 * The version number of this document (it will increase after each
	 * change, including undo/redo).
	 */
	Version int `json:"version"`
	/**
	 * The content of the opened text document.
	 */
	Text string `json:"text"`
}

type TextDocumentPositionParams

type TextDocumentPositionParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Position     Pos                    `json:"position"`
}

type TextEdit

type TextEdit struct {
	Range   Range  `json:"range"`
	NewText string `json:"newText"`
}

func NewTextEdit

func NewTextEdit(rang Range, newText string) *TextEdit

type VersionedTextDocumentIdentifier

type VersionedTextDocumentIdentifier struct {
	TextDocumentIdentifier
	Version int `json:"version"`
}

type WorkspaceEdit

type WorkspaceEdit struct {
	// URI -> TextEdits
	Changes map[string][]TextEdit `json:"changes"`
}

func NewWorkspaceEdit

func NewWorkspaceEdit() WorkspaceEdit

func (*WorkspaceEdit) AddEdit

func (w *WorkspaceEdit) AddEdit(uri string, rang Range, text string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL