Documentation ¶
Index ¶
- Constants
- Variables
- func FileToLanguageID(path string) string
- func FileToURI(path string) string
- func Initialize(s *Server, path string, options interface{}) error
- func String(s string) *string
- func TextDocumentDidClose(s *Server, path string) error
- func TextDocumentDidOpen(s *Server, path string, vers int) error
- type ClientCapabilities
- type DidCloseTextDocumentParams
- type DidOpenTextDocumentParams
- type DocumentSymbolParams
- type InitializeParams
- type Location
- func TextDocumentDefinition(s *Server, file string, line int, col int) ([]Location, error)
- func TextDocumentImplementation(s *Server, file string, line int, col int) ([]Location, error)
- func TextDocumentReferences(s *Server, file string, line int, col int) ([]Location, error)
- func TextDocumentTypeDefinition(s *Server, file string, line int, col int) ([]Location, error)
- type Position
- type Range
- type ReferenceContext
- type ReferenceParams
- type Server
- type ServerOption
- type SymbolInformation
- type SymbolKind
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentPositionParams
- type WorkspaceFolder
Constants ¶
const ( // TraceOff ... TraceOff = "off" // TraceVerbose ... TraceVerbose = "verbose" // TraceMessages ... TraceMessages = "messages" )
Variables ¶
var ErrStopped = errors.New("stopped server")
ErrStopped is returned when a RPC method is called on a stopped Server.
Functions ¶
func FileToLanguageID ¶
FileToLanguageID maps a file extension to a TextDocumentItem identifier. Currently this handles only C++ files.
func TextDocumentDidClose ¶
TextDocumentDidClose ...
Types ¶
type DidCloseTextDocumentParams ¶
type DidCloseTextDocumentParams struct { // The document that was closed. TextDocument TextDocumentIdentifier `json:"textDocument"` }
DidCloseTextDocumentParams is sent from the client to the server when the document got closed in the client. The document’s truth now exists where the document’s uri points to (e.g. if the document’s uri is a file uri the truth now exists on disk).
type DidOpenTextDocumentParams ¶
type DidOpenTextDocumentParams struct { // The document that was opened. TextDocument TextDocumentItem `json:"textDocument"` }
DidOpenTextDocumentParams is sent from the client to the server to signal newly opened text documents. The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s uri. Open in this sense means it is managed by the client.
type DocumentSymbolParams ¶
type DocumentSymbolParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
DocumentSymbolParams ...
type InitializeParams ¶
type InitializeParams struct { // The process Id of the parent process that started the // server. Is null if the process has not been started by // another process. If the parent process is not alive then // the server should exit (see exit notification) its process. // ProcessID int `json:"processId"` // The rootUri of the workspace. Is null if no folder is open. // If both `rootPath` and `rootUri` are set `rootUri` wins. RootURI string `json:"rootUri,omitempty"` InitializationOptions interface{} `json:"initializationOptions"` // The capabilities provided by the client (editor or tool) Capabilities ClientCapabilities `json:"capabilities"` // The initial trace setting. If omitted trace is disabled ('off'). // trace?: 'off' | 'messages' | 'verbose'; Trace string `json:"trace,omitempty"` // The workspace folders configured in the client when the // server starts. This property is only available if the // client supports workspace folders. It can be `null` if the // client supports workspace folders but none are configured. WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders"` }
InitializeParams ...
https://microsoft.github.io/language-server-protocol/specification#initialize
type Location ¶
Location represents a location inside a resource, such as a line inside a text file.
func TextDocumentDefinition ¶
TextDocumentDefinition returns one or more Locations for the definition of the symbol at the given document position. Note that the Ranges in the returned locations (at least for cquery) cover the entire symbol (e.g. the whole class definition, not just the name).
func TextDocumentImplementation ¶
TextDocumentImplementation resolves the implementation location of a symbol at a given text document position.
func TextDocumentReferences ¶
TextDocumentReferences ...
type Position ¶
Position in a text document expressed as zero-based line and zero-based character offset. A position is between two characters like an ‘insert’ cursor in a editor.
type Range ¶
Range is a range in a text document expressed as (zero-based) start and end positions. A range is comparable to a selection in an editor. Therefore the end position is exclusive. If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line.
type ReferenceContext ¶
type ReferenceContext struct { // Include the declaration of the current symbol. IncludeDeclaration bool `json:"includeDeclaration"` }
ReferenceContext ...
type ReferenceParams ¶
type ReferenceParams struct { Context ReferenceContext `json:"context"` TextDocument TextDocumentIdentifier `json:"textDocument"` Position Position `json:"position"` }
ReferenceParams is sent from the client to the server to resolve project-wide references for the symbol denoted by the given text document position.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an instance of a LSP server process.
func (*Server) Call ¶
func (s *Server) Call(ctx context.Context, method string, params interface{}, result interface{}) error
Call ...
type ServerOption ¶
type ServerOption func(*srvOpts)
ServerOption is a startup option for the LDP server.
func OptArgs ¶
func OptArgs(args []string) ServerOption
OptArgs sets additional arguments passed to the LSP server.
func OptPath ¶
func OptPath(path string) ServerOption
OptPath sets the path to the LSP server executable.
func OptTrace ¶
func OptTrace(out io.Writer) ServerOption
OptTrace enables message tracing to the given io.Writer.
type SymbolInformation ¶
type SymbolInformation struct { // Name is the name of this symbol. Name string `json:"name"` // Kind is the kind of this symbol. Kind int `json:"kind"` // Deprecated indicates if this symbol is deprecated. Deprecated bool `json:"deprecated, omitempty"` // Location is the location of this symbol. The location's // range is used by a tool to reveal the location in the // editor. If the symbol is selected in the tool the range's // start information is used to position the cursor. So the // range usually spans more then the actual symbol's name and // does normally include things like visibility modifiers. // // The range doesn't have to denote a node range in the sense // of a abstract syntax tree. It can therefore not be used // to re-construct a hierarchy of the symbols. Location Location `json:"location"` // ContainerName is the name of the symbol containing this // symbol. This information is for user interface purposes // (e.g. to render a qualifier in the user interface if // necessary). It can't be used to re-infer a hierarchy for // the document symbols. ContainerName *string `json:"containerName, omitempty"` }
SymbolInformation represents information about programming constructs like variables, classes,
func TextDocumentDocumentSymbol ¶
func TextDocumentDocumentSymbol(s *Server, path string) ([]SymbolInformation, error)
TextDocumentDocumentSymbol ...
type SymbolKind ¶
type SymbolKind int
SymbolKind ..
const ( // SymbolKindFile ... SymbolKindFile SymbolKind = 1 // SymbolKindModule ... SymbolKindModule SymbolKind = 2 // SymbolKindNamespace ... SymbolKindNamespace SymbolKind = 3 // SymbolKindPackage ... SymbolKindPackage SymbolKind = 4 // SymbolKindClass ... SymbolKindClass SymbolKind = 5 // SymbolKindMethod ... SymbolKindMethod SymbolKind = 6 // SymbolKindProperty ... SymbolKindProperty SymbolKind = 7 // SymbolKindField ... SymbolKindField SymbolKind = 8 // SymbolKindConstructor ... SymbolKindConstructor SymbolKind = 9 // SymbolKindEnum ... SymbolKindEnum SymbolKind = 10 // SymbolKindInterface ... SymbolKindInterface SymbolKind = 11 // SymbolKindFunction ... SymbolKindFunction SymbolKind = 12 // SymbolKindVariable ... SymbolKindVariable SymbolKind = 13 // SymbolKindConstant ... SymbolKindConstant SymbolKind = 14 // SymbolKindString ... SymbolKindString SymbolKind = 15 // SymbolKindNumber ... SymbolKindNumber SymbolKind = 16 // SymbolKindBoolean ... SymbolKindBoolean SymbolKind = 17 // SymbolKindArray ... SymbolKindArray SymbolKind = 18 // SymbolKindObject ... SymbolKindObject SymbolKind = 19 // SymbolKindKey ... SymbolKindKey SymbolKind = 20 // SymbolKindNull ... SymbolKindNull SymbolKind = 21 // SymbolKindEnumMember ... SymbolKindEnumMember SymbolKind = 22 // SymbolKindStruct ... SymbolKindStruct SymbolKind = 23 // SymbolKindEvent ... SymbolKindEvent SymbolKind = 24 // SymbolKindOperator ... SymbolKindOperator SymbolKind = 25 // SymbolKindTypeParameter ... SymbolKindTypeParameter SymbolKind = 26 )
type TextDocumentIdentifier ¶
type TextDocumentIdentifier struct {
URI string `json:"uri"`
}
TextDocumentIdentifier identifies a text documents using a 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"` }
TextDocumentItem is item to transfer a text document from the client to the server.
type TextDocumentPositionParams ¶
type TextDocumentPositionParams struct { TextDocument TextDocumentIdentifier `json:"textDocument"` Position Position `json:"position"` }
TextDocumentPositionParams is a parameter literal used in requests to pass a text document and a position inside that document.
type WorkspaceFolder ¶
type WorkspaceFolder struct { // The associated URI for this workspace folder. URI string `json:"uri"` // The name of the workspace folder. Defaults to the // uri's basename. Name string `json:"name"` }
WorkspaceFolder ...
https://microsoft.github.io/language-server-protocol/specification#workspace_workspaceFolders