lsp

package
v0.0.0-...-34c0a53 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TraceOff ...
	TraceOff = "off"

	// TraceVerbose  ...
	TraceVerbose = "verbose"

	// TraceMessages ...
	TraceMessages = "messages"
)

Variables

View Source
var ErrStopped = errors.New("stopped server")

ErrStopped is returned when a RPC method is called on a stopped Server.

Functions

func FileToLanguageID

func FileToLanguageID(path string) string

FileToLanguageID maps a file extension to a TextDocumentItem identifier. Currently this handles only C++ files.

func FileToURI

func FileToURI(path string) string

FileToURI ...

func Initialize

func Initialize(s *Server, path string, options interface{}) error

Initialize ...

func String

func String(s string) *string

String returns a pointer to its argument.

func TextDocumentDidClose

func TextDocumentDidClose(s *Server, path string) error

TextDocumentDidClose ...

func TextDocumentDidOpen

func TextDocumentDidOpen(s *Server, path string, vers int) error

TextDocumentDidOpen ...

Types

type ClientCapabilities

type ClientCapabilities struct {
}

ClientCapabilities ...

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

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

Location represents a location inside a resource, such as a line inside a text file.

func TextDocumentDefinition

func TextDocumentDefinition(s *Server, file string, line int, col int) ([]Location, error)

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

func TextDocumentImplementation(s *Server, file string, line int, col int) ([]Location, error)

TextDocumentImplementation resolves the implementation location of a symbol at a given text document position.

func TextDocumentReferences

func TextDocumentReferences(s *Server, file string, line int, col int) ([]Location, error)

TextDocumentReferences ...

func TextDocumentTypeDefinition

func TextDocumentTypeDefinition(s *Server, file string, line int, col int) ([]Location, error)

TextDocumentTypeDefinition resolve the type definition location of a symbol at a given text document position.

type Position

type Position struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

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

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

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.

func (Range) After

func (r Range) After(r2 Range) bool

After ...

func (Range) Before

func (r Range) Before(r2 Range) bool

Before ...

func (Range) Contains

func (r Range) Contains(sub Range) bool

Contains returns true if sub is fully contained by this range.

func (Range) LineCount

func (r Range) LineCount() int

LineCount returns the length of the range in lines.

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 NewServer

func NewServer() (*Server, error)

NewServer ...

func (*Server) Call

func (s *Server) Call(ctx context.Context, method string, params interface{}, result interface{}) error

Call ...

func (*Server) Notify

func (s *Server) Notify(ctx context.Context, method string, params interface{}) error

Notify ...

func (*Server) Start

func (s *Server) Start(opts []ServerOption) error

Start ...

func (*Server) Stop

func (s *Server) Stop()

Stop ...

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

Jump to

Keyboard shortcuts

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