Documentation ¶
Overview ¶
Package lsp implements LSP for gopls.
Index ¶
- Constants
- func DiagnosticWorkTitle(cause ModificationSource) string
- type ModificationSource
- type Server
- func (s *Server) CodeAction(ctx context.Context, params *protocol.CodeActionParams) ([]protocol.CodeAction, error)
- func (s *Server) CodeLens(ctx context.Context, params *protocol.CodeLensParams) ([]protocol.CodeLens, error)
- func (s *Server) ColorPresentation(context.Context, *protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error)
- func (s *Server) Completion(ctx context.Context, params *protocol.CompletionParams) (*protocol.CompletionList, error)
- func (s *Server) Declaration(context.Context, *protocol.DeclarationParams) (protocol.Declaration, error)
- func (s *Server) Definition(ctx context.Context, params *protocol.DefinitionParams) (protocol.Definition, error)
- func (s *Server) DidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) error
- func (s *Server) DidChangeConfiguration(ctx context.Context, changed *protocol.DidChangeConfigurationParams) error
- func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) error
- func (s *Server) DidChangeWorkspaceFolders(ctx context.Context, params *protocol.DidChangeWorkspaceFoldersParams) error
- func (s *Server) DidClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) error
- func (s *Server) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error
- func (s *Server) DidSave(ctx context.Context, params *protocol.DidSaveTextDocumentParams) error
- func (s *Server) DocumentColor(context.Context, *protocol.DocumentColorParams) ([]protocol.ColorInformation, error)
- func (s *Server) DocumentHighlight(ctx context.Context, params *protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error)
- func (s *Server) DocumentLink(ctx context.Context, params *protocol.DocumentLinkParams) ([]protocol.DocumentLink, error)
- func (s *Server) DocumentSymbol(ctx context.Context, params *protocol.DocumentSymbolParams) ([]interface{}, error)
- func (s *Server) ExecuteCommand(ctx context.Context, params *protocol.ExecuteCommandParams) (interface{}, error)
- func (s *Server) Exit(ctx context.Context) error
- func (s *Server) FoldingRange(ctx context.Context, params *protocol.FoldingRangeParams) ([]protocol.FoldingRange, error)
- func (s *Server) Formatting(ctx context.Context, params *protocol.DocumentFormattingParams) ([]protocol.TextEdit, error)
- func (s *Server) Hover(ctx context.Context, params *protocol.HoverParams) (*protocol.Hover, error)
- func (s *Server) Implementation(ctx context.Context, params *protocol.ImplementationParams) (protocol.Definition, error)
- func (s *Server) IncomingCalls(context.Context, *protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error)
- func (s *Server) Initialize(ctx context.Context, params *protocol.ParamInitialize) (*protocol.InitializeResult, error)
- func (s *Server) Initialized(ctx context.Context, params *protocol.InitializedParams) error
- func (s *Server) LogTraceNotification(context.Context, *protocol.LogTraceParams) error
- func (s *Server) NonstandardRequest(ctx context.Context, method string, params interface{}) (interface{}, error)
- func (s *Server) OnTypeFormatting(context.Context, *protocol.DocumentOnTypeFormattingParams) ([]protocol.TextEdit, error)
- func (s *Server) OutgoingCalls(context.Context, *protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error)
- func (s *Server) PrepareCallHierarchy(context.Context, *protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error)
- func (s *Server) PrepareRename(ctx context.Context, params *protocol.PrepareRenameParams) (*protocol.Range, error)
- func (s *Server) RangeFormatting(context.Context, *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error)
- func (s *Server) References(ctx context.Context, params *protocol.ReferenceParams) ([]protocol.Location, error)
- func (s *Server) Rename(ctx context.Context, params *protocol.RenameParams) (*protocol.WorkspaceEdit, error)
- func (s *Server) Resolve(context.Context, *protocol.CompletionItem) (*protocol.CompletionItem, error)
- func (s *Server) ResolveCodeLens(context.Context, *protocol.CodeLens) (*protocol.CodeLens, error)
- func (s *Server) ResolveDocumentLink(context.Context, *protocol.DocumentLink) (*protocol.DocumentLink, error)
- func (s *Server) SelectionRange(context.Context, *protocol.SelectionRangeParams) ([]protocol.SelectionRange, error)
- func (s *Server) SemanticTokens(context.Context, *protocol.SemanticTokensParams) (*protocol.SemanticTokens, error)
- func (s *Server) SemanticTokensEdits(context.Context, *protocol.SemanticTokensEditsParams) (interface{}, error)
- func (s *Server) SemanticTokensRange(context.Context, *protocol.SemanticTokensRangeParams) (*protocol.SemanticTokens, error)
- func (s *Server) SetTraceNotification(context.Context, *protocol.SetTraceParams) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) SignatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error)
- func (s *Server) StartWork(ctx context.Context, title, message string, cancel func()) *WorkDone
- func (s *Server) Symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error)
- func (s *Server) TypeDefinition(ctx context.Context, params *protocol.TypeDefinitionParams) (protocol.Definition, error)
- func (s *Server) WillSave(context.Context, *protocol.WillSaveTextDocumentParams) error
- func (s *Server) WillSaveWaitUntil(context.Context, *protocol.WillSaveTextDocumentParams) ([]protocol.TextEdit, error)
- func (s *Server) WorkDoneProgressCancel(ctx context.Context, params *protocol.WorkDoneProgressCancelParams) error
- type WorkDone
Constants ¶
const ( // FromDidOpen is a file modification caused by opening a file. FromDidOpen = ModificationSource(iota) // FromDidChange is a file modification caused by changing a file. FromDidChange // FromDidChangeWatchedFiles is a file modification caused by a change to a watched file. FromDidChangeWatchedFiles // FromDidSave is a file modification caused by a file save. FromDidSave // FromDidClose is a file modification caused by closing a file. FromDidClose FromRegenerateCgo )
const GenerateWorkDoneTitle = "generate"
GenerateWorkDoneTitle is the title used in progress reporting for go generate commands. It is exported for testing purposes.
Variables ¶
This section is empty.
Functions ¶
func DiagnosticWorkTitle ¶
func DiagnosticWorkTitle(cause ModificationSource) string
DiagnosticWorkTitle returns the title of the diagnostic work resulting from a file change originating from the given cause.
Types ¶
type ModificationSource ¶
type ModificationSource int
ModificationSource identifies the originating cause of a file modification.
func (ModificationSource) String ¶
func (m ModificationSource) String() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the protocol.Server interface.
func NewServer ¶
NewServer creates an LSP server and binds it to handle incoming client messages on on the supplied stream.
func (*Server) CodeAction ¶
func (s *Server) CodeAction(ctx context.Context, params *protocol.CodeActionParams) ([]protocol.CodeAction, error)
func (*Server) ColorPresentation ¶
func (s *Server) ColorPresentation(context.Context, *protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error)
func (*Server) Completion ¶
func (s *Server) Completion(ctx context.Context, params *protocol.CompletionParams) (*protocol.CompletionList, error)
func (*Server) Declaration ¶
func (s *Server) Declaration(context.Context, *protocol.DeclarationParams) (protocol.Declaration, error)
func (*Server) Definition ¶
func (s *Server) Definition(ctx context.Context, params *protocol.DefinitionParams) (protocol.Definition, error)
func (*Server) DidChangeConfiguration ¶
func (*Server) DidChangeWatchedFiles ¶
func (*Server) DidChangeWorkspaceFolders ¶
func (*Server) DocumentColor ¶
func (s *Server) DocumentColor(context.Context, *protocol.DocumentColorParams) ([]protocol.ColorInformation, error)
func (*Server) DocumentHighlight ¶
func (s *Server) DocumentHighlight(ctx context.Context, params *protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error)
func (*Server) DocumentLink ¶
func (s *Server) DocumentLink(ctx context.Context, params *protocol.DocumentLinkParams) ([]protocol.DocumentLink, error)
func (*Server) DocumentSymbol ¶
func (*Server) ExecuteCommand ¶
func (*Server) FoldingRange ¶
func (s *Server) FoldingRange(ctx context.Context, params *protocol.FoldingRangeParams) ([]protocol.FoldingRange, error)
func (*Server) Formatting ¶
func (*Server) Implementation ¶
func (s *Server) Implementation(ctx context.Context, params *protocol.ImplementationParams) (protocol.Definition, error)
func (*Server) IncomingCalls ¶
func (s *Server) IncomingCalls(context.Context, *protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error)
func (*Server) Initialize ¶
func (s *Server) Initialize(ctx context.Context, params *protocol.ParamInitialize) (*protocol.InitializeResult, error)
func (*Server) Initialized ¶
func (*Server) LogTraceNotification ¶
func (*Server) NonstandardRequest ¶
func (*Server) OnTypeFormatting ¶
func (*Server) OutgoingCalls ¶
func (s *Server) OutgoingCalls(context.Context, *protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error)
func (*Server) PrepareCallHierarchy ¶
func (s *Server) PrepareCallHierarchy(context.Context, *protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error)
func (*Server) PrepareRename ¶
func (*Server) RangeFormatting ¶
func (*Server) References ¶
func (*Server) Rename ¶
func (s *Server) Rename(ctx context.Context, params *protocol.RenameParams) (*protocol.WorkspaceEdit, error)
func (*Server) Resolve ¶
func (s *Server) Resolve(context.Context, *protocol.CompletionItem) (*protocol.CompletionItem, error)
func (*Server) ResolveCodeLens ¶
func (*Server) ResolveDocumentLink ¶
func (s *Server) ResolveDocumentLink(context.Context, *protocol.DocumentLink) (*protocol.DocumentLink, error)
func (*Server) SelectionRange ¶
func (s *Server) SelectionRange(context.Context, *protocol.SelectionRangeParams) ([]protocol.SelectionRange, error)
func (*Server) SemanticTokens ¶
func (s *Server) SemanticTokens(context.Context, *protocol.SemanticTokensParams) (*protocol.SemanticTokens, error)
func (*Server) SemanticTokensEdits ¶
func (*Server) SemanticTokensRange ¶
func (s *Server) SemanticTokensRange(context.Context, *protocol.SemanticTokensRangeParams) (*protocol.SemanticTokens, error)
func (*Server) SetTraceNotification ¶
func (*Server) SignatureHelp ¶
func (s *Server) SignatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error)
func (*Server) StartWork ¶
StartWork creates a unique token and issues a $/progress notification to begin a unit of work on the server. The returned WorkDone handle may be used to report incremental progress, and to report work completion. In particular, it is an error to call StartWork and not call End(...) on the returned WorkDone handle.
The progress item is considered cancellable if the given cancel func is non-nil.
Example:
func Generate(ctx) (err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() work := s.StartWork(ctx, "generate", "running go generate", cancel) defer func() { if err != nil { work.End(ctx, fmt.Sprintf("generate failed: %v", err)) } else { work.End(ctx, "done") } }() // Do the work... }
func (*Server) Symbol ¶
func (s *Server) Symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error)
func (*Server) TypeDefinition ¶
func (s *Server) TypeDefinition(ctx context.Context, params *protocol.TypeDefinitionParams) (protocol.Definition, error)
func (*Server) WillSaveWaitUntil ¶
func (*Server) WorkDoneProgressCancel ¶
Source Files ¶
- code_action.go
- command.go
- completion.go
- definition.go
- diagnostics.go
- folding_range.go
- format.go
- general.go
- generate.go
- highlight.go
- hover.go
- implementation.go
- link.go
- progress.go
- references.go
- rename.go
- server.go
- server_gen.go
- signature_help.go
- symbols.go
- text_synchronization.go
- workspace.go
- workspace_symbol.go
Directories ¶
Path | Synopsis |
---|---|
analysis
|
|
fillreturns
Package fillreturns defines an Analyzer that will attempt to automatically fill in a return statement that has missing values with zero value elements.
|
Package fillreturns defines an Analyzer that will attempt to automatically fill in a return statement that has missing values with zero value elements. |
fillstruct
Package fillstruct defines an Analyzer that automatically fills in a struct declaration with zero value elements for each field.
|
Package fillstruct defines an Analyzer that automatically fills in a struct declaration with zero value elements for each field. |
nonewvars
Package nonewvars defines an Analyzer that applies suggested fixes to errors of the type "no new variables on left side of :=".
|
Package nonewvars defines an Analyzer that applies suggested fixes to errors of the type "no new variables on left side of :=". |
noresultvalues
Package noresultvalues defines an Analyzer that applies suggested fixes to errors of the type "no result values expected".
|
Package noresultvalues defines an Analyzer that applies suggested fixes to errors of the type "no result values expected". |
simplifycompositelit
Package simplifycompositelit defines an Analyzer that simplifies composite literals.
|
Package simplifycompositelit defines an Analyzer that simplifies composite literals. |
simplifyrange
Package simplifyrange defines an Analyzer that simplifies range statements.
|
Package simplifyrange defines an Analyzer that simplifies range statements. |
simplifyslice
Package simplifyslice defines an Analyzer that simplifies slice statements.
|
Package simplifyslice defines an Analyzer that simplifies slice statements. |
undeclaredname
Package undeclaredname defines an Analyzer that applies suggested fixes to errors of the type "undeclared name: %s".
|
Package undeclaredname defines an Analyzer that applies suggested fixes to errors of the type "undeclared name: %s". |
unusedparams
Package unusedparams defines an analyzer that checks for unused parameters of functions.
|
Package unusedparams defines an analyzer that checks for unused parameters of functions. |
Package browser provides utilities for interacting with users' browsers.
|
Package browser provides utilities for interacting with users' browsers. |
Package cache implements the caching layer for gopls.
|
Package cache implements the caching layer for gopls. |
Package cmd handles the gopls command line.
|
Package cmd handles the gopls command line. |
test
Package cmdtest contains the test suite for the command line behavior of gopls.
|
Package cmdtest contains the test suite for the command line behavior of gopls. |
Package debug exports debug information for gopls.
|
Package debug exports debug information for gopls. |
tag
Package tag provides the labels used for telemetry throughout gopls.
|
Package tag provides the labels used for telemetry throughout gopls. |
Package diff supports a pluggable diff algorithm.
|
Package diff supports a pluggable diff algorithm. |
difftest
Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by "golang.org/x/tools/internal/lsp/diff"
|
Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by "golang.org/x/tools/internal/lsp/diff" |
myers
Package myers implements the Myers diff algorithm.
|
Package myers implements the Myers diff algorithm. |
Package fake provides fake implementations of a text editor, LSP client plugin, and Sandbox environment for use in tests.
|
Package fake provides fake implementations of a text editor, LSP client plugin, and Sandbox environment for use in tests. |
Package fuzzy implements a fuzzy matching algorithm.
|
Package fuzzy implements a fuzzy matching algorithm. |
Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp
|
Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp |
Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
|
Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel. |
Package mod provides core features related to go.mod file handling for use by Go editors and tools.
|
Package mod provides core features related to go.mod file handling for use by Go editors and tools. |
Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
|
Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol". |
Package regtest provides a framework for writing gopls regression tests.
|
Package regtest provides a framework for writing gopls regression tests. |
Package snippet implements the specification for the LSP snippet format.
|
Package snippet implements the specification for the LSP snippet format. |
Package source provides core features for use by Go editors and tools.
|
Package source provides core features for use by Go editors and tools. |
Package tests exports functionality to be used across a variety of gopls tests.
|
Package tests exports functionality to be used across a variety of gopls tests. |