Documentation
¶
Overview ¶
Package lsp is the language server behind ant lsp: it speaks the Language Server Protocol over a stream, analyzing each open document as the root of its own program.
Index ¶
- Constants
- func Serve(ctx context.Context, r io.Reader, w io.Writer, logw io.Writer) int
- type ClientCapabilities
- type Code
- func (c *Code) Def(loc string) (CodeLoc, string, *CodeError)
- func (c *Code) Refs(loc string, decl bool) (RefsResult, *CodeError)
- func (c *Code) Rename(loc, name string, force bool) (RenameResult, *CodeError)
- func (c *Code) Symbols(paths []string, match string, all bool) ([]CodeSymbol, []string, *CodeError)
- func (c *Code) Type(loc string) (TypeResult, *CodeError)
- type CodeAction
- type CodeActionOptions
- type CodeActionParams
- type CodeDiag
- type CodeEdit
- type CodeError
- type CodeFile
- type CodeLens
- type CodeLensOptions
- type CodeLensParams
- type CodeLoc
- type CodeRef
- type CodeSymbol
- type Command
- type CompletionContext
- type CompletionItem
- type CompletionLabelDetails
- type CompletionList
- type CompletionOptions
- type CompletionParams
- type Diagnostic
- type DiagnosticRelatedInformation
- type DidChangeTextDocumentParams
- type DidChangeWatchedFilesParams
- type DidCloseTextDocumentParams
- type DidOpenTextDocumentParams
- type DidSaveTextDocumentParams
- type DocumentFormattingParams
- type DocumentHighlight
- type DocumentSymbol
- type DocumentSymbolParams
- type FileEvent
- type FoldingRange
- type FoldingRangeParams
- type Hover
- type InitializeParams
- type InitializeResult
- type InlayHint
- type InlayHintParams
- type Location
- type LogMessageParams
- type MarkupContent
- type ParameterInformation
- type Position
- type PublishDiagnosticsParams
- type Range
- type ReferenceParams
- type RefsResult
- type RenameOptions
- type RenameParams
- type RenameResult
- type SelectionRange
- type SelectionRangeParams
- type SemanticTokens
- type SemanticTokensLegend
- type SemanticTokensOptions
- type SemanticTokensParams
- type Server
- type ServerCapabilities
- type ServerInfo
- type ShowMessageParams
- type SignatureHelp
- type SignatureHelpContext
- type SignatureHelpOptions
- type SignatureHelpParams
- type SignatureInformation
- type SourceParams
- type SymbolInformation
- type TextDocumentContentChangeEvent
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentPositionParams
- type TextDocumentSyncOptions
- type TextEdit
- type TypeResult
- type VersionedTextDocumentIdentifier
- type WorkspaceEdit
- type WorkspaceFolder
- type WorkspaceSymbolParams
Constants ¶
const ( ItemText = 1 ItemMethod = 2 ItemFunction = 3 ItemConstructor = 4 ItemField = 5 ItemVariable = 6 ItemClass = 7 ItemInterface = 8 ItemModule = 9 ItemProperty = 10 ItemUnit = 11 ItemValue = 12 ItemEnum = 13 ItemKeyword = 14 ItemSnippet = 15 ItemFile = 17 ItemReference = 18 ItemFolder = 19 ItemConstant = 21 ItemStruct = 22 ItemTypeParameter = 25 )
The completion item kinds the server uses.
const ( SymbolFile = 1 SymbolModule = 2 SymbolNamespace = 3 SymbolPackage = 4 SymbolClass = 5 SymbolMethod = 6 SymbolProperty = 7 SymbolField = 8 SymbolConstructor = 9 SymbolEnum = 10 SymbolInterface = 11 SymbolFunction = 12 SymbolVariable = 13 SymbolConstant = 14 SymbolString = 15 SymbolStruct = 23 SymbolTypeParameter = 26 )
The symbol kinds the server uses.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientCapabilities ¶
type ClientCapabilities struct {
General struct {
PositionEncodings []string `json:"positionEncodings"`
} `json:"general"`
TextDocument struct {
Completion struct {
CompletionItem struct {
SnippetSupport bool `json:"snippetSupport"`
DocumentationFormat []string `json:"documentationFormat"`
LabelDetailsSupport bool `json:"labelDetailsSupport"`
} `json:"completionItem"`
} `json:"completion"`
Hover struct {
ContentFormat []string `json:"contentFormat"`
} `json:"hover"`
SignatureHelp struct {
SignatureInformation struct {
DocumentationFormat []string `json:"documentationFormat"`
ParameterInformation struct {
LabelOffsetSupport bool `json:"labelOffsetSupport"`
} `json:"parameterInformation"`
} `json:"signatureInformation"`
} `json:"signatureHelp"`
DocumentSymbol struct {
HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport"`
} `json:"documentSymbol"`
Rename struct {
PrepareSupport bool `json:"prepareSupport"`
} `json:"rename"`
} `json:"textDocument"`
Workspace struct {
DidChangeWatchedFiles struct {
DynamicRegistration bool `json:"dynamicRegistration"`
} `json:"didChangeWatchedFiles"`
} `json:"workspace"`
}
ClientCapabilities is the part of the client's capabilities the server reads.
type Code ¶ added in v0.3.0
type Code struct {
// contains filtered or unexported fields
}
Code answers the requests of ant code with the server's own analysis, in process: a server whose workspace folder is the root, which counts columns in bytes, and whose open documents are the files as they are on disk, each read once.
func (*Code) Def ¶ added in v0.3.0
Def answers ant code def: where the name at loc is declared, and its signature on one line.
func (*Code) Refs ¶ added in v0.3.0
func (c *Code) Refs(loc string, decl bool) (RefsResult, *CodeError)
Refs answers ant code refs: the uses of the declaration loc selects, and the declaration itself with decl.
func (*Code) Rename ¶ added in v0.3.0
func (c *Code) Rename(loc, name string, force bool) (RenameResult, *CodeError)
Rename answers ant code rename: the edits that rename the declaration loc selects to name, or why it cannot be renamed. With force, a program with errors or an incomplete search does not stop it, and the result carries the errors and the files skipped.
func (*Code) Symbols ¶ added in v0.3.0
Symbols answers ant code symbols: the declarations of the modules under each path, the root when there is none, whose names contain match, without regard to case; with all, the fields of record types and the declarations in functions too. It also returns the files with syntax errors, whose declarations are those it recovered.
type CodeAction ¶
type CodeAction struct {
Title string `json:"title"`
Kind string `json:"kind,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
IsPreferred bool `json:"isPreferred,omitempty"`
Edit *WorkspaceEdit `json:"edit,omitempty"`
}
type CodeActionOptions ¶
type CodeActionOptions struct {
CodeActionKinds []string `json:"codeActionKinds"`
}
type CodeActionParams ¶
type CodeActionParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Range Range `json:"range"`
Context struct {
Diagnostics []Diagnostic `json:"diagnostics"`
Only []string `json:"only"`
} `json:"context"`
}
type CodeError ¶ added in v0.3.0
type CodeError struct {
Code string
Message string
Candidates []CodeLoc // for ambiguous
Errors []CodeDiag // for check
Skipped []string // for incomplete
// contains filtered or unexported fields
}
CodeError is a request ant code could not answer, with its code.
type CodeFile ¶ added in v0.3.0
CodeFile is a file a rename changes: its edits in source order, the text they were found in, and the text they make.
type CodeLensOptions ¶
type CodeLensOptions struct {
ResolveProvider bool `json:"resolveProvider"`
}
type CodeLensParams ¶
type CodeLensParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
type CodeLoc ¶ added in v0.3.0
type CodeLoc struct {
Path string
Prelude bool
Start, End ast.Pos
// Line is the source line the location starts on, without its line break.
Line string
}
CodeLoc is the location of a name or an expression: the file, as the analysis spells its path (absolute, or prelude.Path for the prelude), and the span, in lines and byte columns from 1.
type CodeRef ¶ added in v0.3.0
CodeRef is a use refs reports, with the alias it is written through, if any.
type CodeSymbol ¶ added in v0.3.0
type CodeSymbol struct {
Loc CodeLoc
Kind string
Name string
Signature string
Exported bool
Container string
}
CodeSymbol is a declaration symbols lists.
type CompletionContext ¶
type CompletionItem ¶
type CompletionItem struct {
Label string `json:"label"`
LabelDetails *CompletionLabelDetails `json:"labelDetails,omitempty"`
Kind int `json:"kind,omitempty"`
Detail string `json:"detail,omitempty"`
Documentation *MarkupContent `json:"documentation,omitempty"`
SortText string `json:"sortText,omitempty"`
FilterText string `json:"filterText,omitempty"`
InsertText string `json:"insertText,omitempty"`
InsertTextFormat int `json:"insertTextFormat,omitempty"` // 1 plain, 2 snippet
TextEdit *TextEdit `json:"textEdit,omitempty"`
CommitCharacters []string `json:"commitCharacters,omitempty"`
// AdditionalTextEdits are made with the item, elsewhere in the document: an import.
AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"`
}
func Complete ¶
func Complete(cfg loader.Config, path, text string, off int) []CompletionItem
Complete lists what can be written at byte offset off of text, the input of a session at path, for a REPL: cfg is the session's loader configuration, whose Session scope and Extra names the input is resolved against; the text itself overrides whatever cfg.Sources holds at path. The text is parsed as a script, since the checker types the statements of a script and not those of a session input; the scope still lets a name be declared again. The items are those the language server would offer, unsorted.
type CompletionLabelDetails ¶
type CompletionList ¶
type CompletionList struct {
IsIncomplete bool `json:"isIncomplete"`
Items []CompletionItem `json:"items"`
}
type CompletionOptions ¶
type CompletionParams ¶
type CompletionParams struct {
TextDocumentPositionParams
Context *CompletionContext `json:"context"`
}
type Diagnostic ¶
type Diagnostic struct {
Range Range `json:"range"`
Severity int `json:"severity"` // 1 error, 2 warning, 3 information, 4 hint
Code string `json:"code,omitempty"`
Tags []int `json:"tags,omitempty"` // 1 unnecessary
Source string `json:"source"`
Message string `json:"message"`
RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
}
type DidChangeTextDocumentParams ¶
type DidChangeTextDocumentParams struct {
TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`
ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
}
type DidChangeWatchedFilesParams ¶
type DidChangeWatchedFilesParams struct {
Changes []FileEvent `json:"changes"`
}
type DidCloseTextDocumentParams ¶
type DidCloseTextDocumentParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
type DidOpenTextDocumentParams ¶
type DidOpenTextDocumentParams struct {
TextDocument TextDocumentItem `json:"textDocument"`
}
type DidSaveTextDocumentParams ¶
type DidSaveTextDocumentParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
type DocumentFormattingParams ¶
type DocumentFormattingParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Options struct {
TabSize int `json:"tabSize"`
InsertSpaces bool `json:"insertSpaces"`
} `json:"options"`
}
type DocumentHighlight ¶
type DocumentSymbol ¶
type DocumentSymbolParams ¶
type DocumentSymbolParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
type FoldingRange ¶
type FoldingRangeParams ¶
type FoldingRangeParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
type Hover ¶
type Hover struct {
Contents MarkupContent `json:"contents"`
Range *Range `json:"range,omitempty"`
}
type InitializeParams ¶
type InitializeParams struct {
ProcessID *int `json:"processId"`
RootURI string `json:"rootUri"`
Capabilities ClientCapabilities `json:"capabilities"`
WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders"`
ClientInfo *struct {
Name string `json:"name"`
Version string `json:"version"`
} `json:"clientInfo"`
}
type InitializeResult ¶
type InitializeResult struct {
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
}
type InlayHintParams ¶
type InlayHintParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Range Range `json:"range"`
}
type LogMessageParams ¶
type MarkupContent ¶
type ParameterInformation ¶
type ParameterInformation struct {
Label [2]int `json:"label"`
Documentation *MarkupContent `json:"documentation,omitempty"`
}
ParameterInformation names a parameter by the offsets of its label in the signature's label.
type Position ¶
Position is a line and a character in a document, both from 0. The character counts UTF-16 code units, or bytes when the client agreed to utf-8.
type PublishDiagnosticsParams ¶
type PublishDiagnosticsParams struct {
URI string `json:"uri"`
Version *int `json:"version,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics"`
}
type ReferenceParams ¶
type ReferenceParams struct {
TextDocumentPositionParams
Context struct {
IncludeDeclaration bool `json:"includeDeclaration"`
} `json:"context"`
}
type RefsResult ¶ added in v0.3.0
type RefsResult struct {
// Decl is the declaration's location; nil for a namespace of the prelude, which has none.
Decl *CodeLoc
Refs []CodeRef
Skipped []string
}
RefsResult is the answer of ant code refs.
type RenameOptions ¶
type RenameOptions struct {
PrepareProvider bool `json:"prepareProvider"`
}
type RenameParams ¶
type RenameParams struct {
TextDocumentPositionParams
NewName string `json:"newName"`
}
type RenameResult ¶ added in v0.3.0
type RenameResult struct {
Files []CodeFile
Skipped []string
// Errors are the errors of the programs the rename changes, which force let through.
Errors []CodeDiag
}
RenameResult is the answer of ant code rename.
type SelectionRange ¶
type SelectionRange struct {
Range Range `json:"range"`
Parent *SelectionRange `json:"parent,omitempty"`
}
type SelectionRangeParams ¶
type SelectionRangeParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Positions []Position `json:"positions"`
}
type SemanticTokens ¶
type SemanticTokens struct {
Data []uint32 `json:"data"`
}
type SemanticTokensLegend ¶
type SemanticTokensOptions ¶
type SemanticTokensOptions struct {
Legend SemanticTokensLegend `json:"legend"`
Full bool `json:"full"`
}
type SemanticTokensParams ¶
type SemanticTokensParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is one language server, serving one client.
type ServerCapabilities ¶
type ServerCapabilities struct {
PositionEncoding string `json:"positionEncoding,omitempty"`
TextDocumentSync TextDocumentSyncOptions `json:"textDocumentSync"`
CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"`
HoverProvider bool `json:"hoverProvider"`
SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"`
DefinitionProvider bool `json:"definitionProvider"`
ReferencesProvider bool `json:"referencesProvider"`
DocumentHighlightProvider bool `json:"documentHighlightProvider"`
DocumentSymbolProvider bool `json:"documentSymbolProvider"`
WorkspaceSymbolProvider bool `json:"workspaceSymbolProvider"`
CodeActionProvider *CodeActionOptions `json:"codeActionProvider,omitempty"`
DocumentFormattingProvider bool `json:"documentFormattingProvider"`
RenameProvider *RenameOptions `json:"renameProvider,omitempty"`
FoldingRangeProvider bool `json:"foldingRangeProvider"`
SelectionRangeProvider bool `json:"selectionRangeProvider"`
SemanticTokensProvider *SemanticTokensOptions `json:"semanticTokensProvider,omitempty"`
InlayHintProvider bool `json:"inlayHintProvider"`
CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"`
}
type ServerInfo ¶
type ShowMessageParams ¶
type SignatureHelp ¶
type SignatureHelp struct {
Signatures []SignatureInformation `json:"signatures"`
ActiveSignature int `json:"activeSignature"`
ActiveParameter int `json:"activeParameter"`
}
type SignatureHelpContext ¶
type SignatureHelpContext struct {
TriggerKind int `json:"triggerKind"`
TriggerCharacter string `json:"triggerCharacter"`
IsRetrigger bool `json:"isRetrigger"`
ActiveSignatureHelp *SignatureHelp `json:"activeSignatureHelp"`
}
type SignatureHelpOptions ¶
type SignatureHelpParams ¶
type SignatureHelpParams struct {
TextDocumentPositionParams
Context *SignatureHelpContext `json:"context"`
}
type SignatureInformation ¶
type SignatureInformation struct {
Label string `json:"label"`
Documentation *MarkupContent `json:"documentation,omitempty"`
Parameters []ParameterInformation `json:"parameters"`
ActiveParameter *int `json:"activeParameter,omitempty"`
}
type SourceParams ¶
type SourceParams struct {
URI string `json:"uri"`
}
SourceParams is the parameter of the request ant/source, which the client makes for the text of a document the server owns, such as the prelude.
type SymbolInformation ¶
type TextDocumentContentChangeEvent ¶
type TextDocumentContentChangeEvent struct {
Range *Range `json:"range"`
Text string `json:"text"`
}
TextDocumentContentChangeEvent replaces Range by Text, or the whole document when Range is nil.
type TextDocumentIdentifier ¶
type TextDocumentIdentifier struct {
URI string `json:"uri"`
}
type TextDocumentItem ¶
type TextDocumentPositionParams ¶
type TextDocumentPositionParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Position Position `json:"position"`
}
type TextDocumentSyncOptions ¶
type TypeResult ¶ added in v0.3.0
TypeResult is the answer of ant code type.
type WorkspaceEdit ¶
WorkspaceEdit lists the edits to make in each document.
type WorkspaceFolder ¶
type WorkspaceSymbolParams ¶
type WorkspaceSymbolParams struct {
Query string `json:"query"`
}