lsp

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a LSP client to a Server. It is passed to all methods and is used to post non-requested responses to the server.

func (*Client) ApplyEdit

func (c *Client) ApplyEdit(params *protocol.ApplyWorkspaceEditParams) (bool, error)

func (*Client) Configuration

func (c *Client) Configuration(params *protocol.ConfigurationParams) ([]interface{}, error)

func (*Client) Context

func (c *Client) Context() context.Context

Retrieve the Context of method that Client was passed with.

func (*Client) LogDebugf

func (c *Client) LogDebugf(msg string, args ...interface{}) error

func (*Client) LogErrorf

func (c *Client) LogErrorf(msg string, args ...interface{}) error

func (*Client) LogInfof

func (c *Client) LogInfof(msg string, args ...interface{}) error

func (*Client) LogWarningf

func (c *Client) LogWarningf(msg string, args ...interface{}) error

func (*Client) Progress

func (c *Client) Progress(params *protocol.ProgressParams) error

func (*Client) PublishDiagnostics

func (c *Client) PublishDiagnostics(params *protocol.PublishDiagnosticsParams) error

Publish diagnostic messages to the user. This is how errors and warnings are displayed. Every time diagnostics are published, the complete list of current diagnostics must be published. Diagnostics persist until a new set of diagnostics are published.

To clear all diagnostics, publish an empty list of diagnostics.

func (*Client) RegisterCapability

func (c *Client) RegisterCapability(params *protocol.RegistrationParams) error

func (*Client) ShowMessage

func (c *Client) ShowMessage(params *protocol.ShowMessageParams) error

func (*Client) ShowMessageRequest

func (c *Client) ShowMessageRequest(params *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error)

func (*Client) Telemetry

func (c *Client) Telemetry(params interface{}) error

func (*Client) UnregisterCapability

func (c *Client) UnregisterCapability(params *protocol.UnregistrationParams) error

func (*Client) WorkDoneProgressCreate

func (c *Client) WorkDoneProgressCreate(params *protocol.WorkDoneProgressCreateParams) error

func (*Client) WorkspaceFolders

func (c *Client) WorkspaceFolders() ([]protocol.WorkspaceFolder, error)

type Document

type Document struct {
	// contains filtered or unexported fields
}

A thread-safe text document designed to handle incremental updates.

func NewDocument

func NewDocument(item protocol.TextDocumentItem) Document

Create a new document from a TextDocumentItem.

func (*Document) AcceptChanges

func (t *Document) AcceptChanges(changes []protocol.TextDocumentContentChangeEvent) error

Update the document with the given changes.

func (*Document) Line

func (d *Document) Line(i int) (string, error)

Retrieve a specific line in the document. If the index is out of range (or negative), an error is returned.

func (*Document) LineLen

func (d *Document) LineLen() int

func (*Document) String

func (d *Document) String() string

Returns the whole document as a string.

func (*Document) URI

func (d *Document) URI() protocol.DocumentURI

Retrieve the URI of the Document.

func (*Document) Window

func (d *Document) Window(window protocol.Range) (string, error)

Window provides the text of the document that fits in the window.

type Methods

type Methods struct {
	InitializeFunc                func(client Client, params *protocol.InitializeParams) (result *protocol.InitializeResult, err error)
	InitializedFunc               func(client Client, params *protocol.InitializedParams) (err error)
	ShutdownFunc                  func(client Client) (err error)
	ExitFunc                      func(client Client) (err error)
	WorkDoneProgressCancelFunc    func(client Client, params *protocol.WorkDoneProgressCancelParams) (err error)
	LogTraceFunc                  func(client Client, params *protocol.LogTraceParams) (err error)
	SetTraceFunc                  func(client Client, params *protocol.SetTraceParams) (err error)
	CodeActionFunc                func(client Client, params *protocol.CodeActionParams) (result []protocol.CodeAction, err error)
	CodeLensFunc                  func(client Client, params *protocol.CodeLensParams) (result []protocol.CodeLens, err error)
	CodeLensResolveFunc           func(client Client, params *protocol.CodeLens) (result *protocol.CodeLens, err error)
	ColorPresentationFunc         func(client Client, params *protocol.ColorPresentationParams) (result []protocol.ColorPresentation, err error)
	CompletionFunc                func(client Client, params *protocol.CompletionParams) (result *protocol.CompletionList, err error)
	CompletionResolveFunc         func(client Client, params *protocol.CompletionItem) (result *protocol.CompletionItem, err error)
	DeclarationFunc               func(client Client, params *protocol.DeclarationParams) (result []protocol.Location, err error)
	DefinitionFunc                func(client Client, params *protocol.DefinitionParams) (result []protocol.Location, err error)
	DidChangeFunc                 func(client Client, params *protocol.DidChangeTextDocumentParams) (err error)
	DidChangeConfigurationFunc    func(client Client, params *protocol.DidChangeConfigurationParams) (err error)
	DidChangeWatchedFilesFunc     func(client Client, params *protocol.DidChangeWatchedFilesParams) (err error)
	DidChangeWorkspaceFoldersFunc func(client Client, params *protocol.DidChangeWorkspaceFoldersParams) (err error)
	DidCloseFunc                  func(client Client, params *protocol.DidCloseTextDocumentParams) (err error)
	DidOpenFunc                   func(client Client, params *protocol.DidOpenTextDocumentParams) (err error)
	DidSaveFunc                   func(client Client, params *protocol.DidSaveTextDocumentParams) (err error)
	DocumentColorFunc             func(client Client, params *protocol.DocumentColorParams) (result []protocol.ColorInformation, err error)
	DocumentHighlightFunc         func(client Client, params *protocol.DocumentHighlightParams) (result []protocol.DocumentHighlight, err error)
	DocumentLinkFunc              func(client Client, params *protocol.DocumentLinkParams) (result []protocol.DocumentLink, err error)
	DocumentLinkResolveFunc       func(client Client, params *protocol.DocumentLink) (result *protocol.DocumentLink, err error)
	DocumentSymbolFunc            func(client Client, params *protocol.DocumentSymbolParams) (result []interface{}, err error)
	ExecuteCommandFunc            func(client Client, params *protocol.ExecuteCommandParams) (result interface{}, err error)
	FoldingRangesFunc             func(client Client, params *protocol.FoldingRangeParams) (result []protocol.FoldingRange, err error)
	FormattingFunc                func(client Client, params *protocol.DocumentFormattingParams) (result []protocol.TextEdit, err error)
	HoverFunc                     func(client Client, params *protocol.HoverParams) (result *protocol.Hover, err error)
	ImplementationFunc            func(client Client, params *protocol.ImplementationParams) (result []protocol.Location, err error)
	OnTypeFormattingFunc          func(client Client, params *protocol.DocumentOnTypeFormattingParams) (result []protocol.TextEdit, err error)
	PrepareRenameFunc             func(client Client, params *protocol.PrepareRenameParams) (result *protocol.Range, err error)
	RangeFormattingFunc           func(client Client, params *protocol.DocumentRangeFormattingParams) (result []protocol.TextEdit, err error)
	ReferencesFunc                func(client Client, params *protocol.ReferenceParams) (result []protocol.Location, err error)
	RenameFunc                    func(client Client, params *protocol.RenameParams) (result *protocol.WorkspaceEdit, err error)
	SignatureHelpFunc             func(client Client, params *protocol.SignatureHelpParams) (result *protocol.SignatureHelp, err error)
	SymbolsFunc                   func(client Client, params *protocol.WorkspaceSymbolParams) (result []protocol.SymbolInformation, err error)
	TypeDefinitionFunc            func(client Client, params *protocol.TypeDefinitionParams) (result []protocol.Location, err error)
	WillSaveFunc                  func(client Client, params *protocol.WillSaveTextDocumentParams) (err error)
	WillSaveWaitUntilFunc         func(client Client, params *protocol.WillSaveTextDocumentParams) (result []protocol.TextEdit, err error)
	ShowDocumentFunc              func(client Client, params *protocol.ShowDocumentParams) (result *protocol.ShowDocumentResult, err error)
	WillCreateFilesFunc           func(client Client, params *protocol.CreateFilesParams) (result *protocol.WorkspaceEdit, err error)
	DidCreateFilesFunc            func(client Client, params *protocol.CreateFilesParams) (err error)
	WillRenameFilesFunc           func(client Client, params *protocol.RenameFilesParams) (result *protocol.WorkspaceEdit, err error)
	DidRenameFilesFunc            func(client Client, params *protocol.RenameFilesParams) (err error)
	WillDeleteFilesFunc           func(client Client, params *protocol.DeleteFilesParams) (result *protocol.WorkspaceEdit, err error)
	DidDeleteFilesFunc            func(client Client, params *protocol.DeleteFilesParams) (err error)
	CodeLensRefreshFunc           func(client Client) (err error)
	PrepareCallHierarchyFunc      func(client Client, params *protocol.CallHierarchyPrepareParams) (result []protocol.CallHierarchyItem, err error)
	IncomingCallsFunc             func(client Client, params *protocol.CallHierarchyIncomingCallsParams) (result []protocol.CallHierarchyIncomingCall, err error)
	OutgoingCallsFunc             func(client Client, params *protocol.CallHierarchyOutgoingCallsParams) (result []protocol.CallHierarchyOutgoingCall, err error)
	SemanticTokensFullFunc        func(client Client, params *protocol.SemanticTokensParams) (result *protocol.SemanticTokens, err error)
	SemanticTokensFullDeltaFunc   func(client Client, params *protocol.SemanticTokensDeltaParams) (result interface{}, err error)
	SemanticTokensRangeFunc       func(client Client, params *protocol.SemanticTokensRangeParams) (result *protocol.SemanticTokens, err error)
	SemanticTokensRefreshFunc     func(client Client) (err error)
	LinkedEditingRangeFunc        func(client Client, params *protocol.LinkedEditingRangeParams) (result *protocol.LinkedEditingRanges, err error)
	MonikerFunc                   func(client Client, params *protocol.MonikerParams) (result []protocol.Moniker, err error)
	RequestFunc                   func(client Client, method string, params interface{}) (result interface{}, err error)
	// contains filtered or unexported fields
}

Methods provides the interface to define methods for the LSP server. When the lsp server calls a method that is not provided, it will log a warning and return the zero value for the method's return type.

func (Methods) DefaultInitializer

func (m Methods) DefaultInitializer(name, version string) *Methods

Guess what capabilities should be enabled from what functions are registered.

NOTE: To be accurate, this method should be called on an otherwise fully initialized *Methods. NOTE: This function will panic if a `InitializeFunc` is already set.

type Server

type Server struct {

	// The logger used by the server.
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}

A Server combines a set of LSP methods with the infrastructure needed to fullfill the server side of the LSP contract.

func NewServer

func NewServer(methods *Methods, conn io.ReadWriteCloser) Server

Create a new server backed by `Methods`. The server reads requests and writes responses via `conn`.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Synchronously run the server. The server is rooted in the given context, which can be used to cancel the server.

Jump to

Keyboard shortcuts

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