lsproto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonGetPath

func JsonGetPath(v interface{}, path string) (interface{}, error)

func RangeToOffsetLen

func RangeToOffsetLen(rd iorw.Reader, rang *Range) (int, int, error)

func RegistrationExamples

func RegistrationExamples() string

func RegistrationString

func RegistrationString(reg *Registration) string

func Utf16Column

func Utf16Column(rd iorw.Reader, lineStartOffset, utf8Col int) (int, error)

func Utf8Column

func Utf8Column(rd iorw.Reader, lineStartOffset, utf16Col int) (int, error)

Input and result is zero based.

Types

type Client

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

func NewClientIO

func NewClientIO(rwc io.ReadWriteCloser, li *LangInstance) *Client

func NewClientTCP

func NewClientTCP(ctx context.Context, addr string, li *LangInstance) (*Client, error)

func (*Client) Call

func (cli *Client) Call(ctx context.Context, method string, args, reply interface{}) error

func (*Client) ExitNotification

func (cli *Client) ExitNotification() error

func (*Client) Initialize

func (cli *Client) Initialize(ctx context.Context, filename string) error

Filename is the file that triggered the server to be started.

func (*Client) ShutdownRequest

func (cli *Client) ShutdownRequest() error

func (*Client) TextDocumentCompletion

func (cli *Client) TextDocumentCompletion(ctx context.Context, filename string, pos Position) (*CompletionList, error)

func (*Client) TextDocumentDefinition

func (cli *Client) TextDocumentDefinition(ctx context.Context, filename string, pos Position) (*Location, error)

func (*Client) TextDocumentDidChange

func (cli *Client) TextDocumentDidChange(ctx context.Context, filename, text string, version int) error

func (*Client) TextDocumentDidClose

func (cli *Client) TextDocumentDidClose(ctx context.Context, filename string) error

func (*Client) TextDocumentDidOpen

func (cli *Client) TextDocumentDidOpen(ctx context.Context, filename, text string, version int) error

func (*Client) TextDocumentDidOpenVersion

func (cli *Client) TextDocumentDidOpenVersion(ctx context.Context, filename string, b []byte) error

func (*Client) TextDocumentDidSave

func (cli *Client) TextDocumentDidSave(ctx context.Context, filename string, text []byte) error

func (*Client) UpdateWorkspaceFolder

func (cli *Client) UpdateWorkspaceFolder(ctx context.Context, dir string) error

func (*Client) WorkspaceDidChangeWorkspaceFolders

func (cli *Client) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, added, removed []*WorkspaceFolder) error

type ClientCapabilities

type ClientCapabilities struct {
	TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"`
	Workspace    *WorkspaceClientCapabilities    `json:"workspace,omitempty"`
}

type CompletionContext

type CompletionContext struct {
	TriggerKind      int    `json:"triggerKind"` // 1=invoked, 2=char, 3=re-trigger
	TriggerCharacter string `json:"triggerCharacter,omitempty"`
}

type CompletionItem

type CompletionItem struct {
	Label         string `json:"label"`
	Kind          int    `json:"kind,omitempty"`
	Detail        string `json:"detail,omitempty"`
	Documentation string `json:"documentation,omitempty"`
	Deprecated    bool   `json:"deprecated,omitempty"`
}

type CompletionList

type CompletionList struct {
	IsIncomplete bool              `json:"isIncomplete"`
	Items        []*CompletionItem `json:"items"`
}

type CompletionParams

type CompletionParams struct {
	TextDocumentPositionParams
	Context CompletionContext `json:"context"`
}

type DidChangeTextDocumentParams

type DidChangeTextDocumentParams struct {
	TextDocument   VersionedTextDocumentIdentifier   `json:"textDocument,omitempty"`
	ContentChanges []*TextDocumentContentChangeEvent `json:"contentChanges,omitempty"`
}

type DidChangeWorkspaceFoldersParams

type DidChangeWorkspaceFoldersParams struct {
	Event *WorkspaceFoldersChangeEvent `json:"event,omitempty"`
}

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"`
	Text         string                 `json:"text,omitempty"`
}

type InitializeParams

type InitializeParams struct {
	RootUri          *string             `json:"rootUri"`
	Capabilities     *ClientCapabilities `json:"capabilities,omitempty"`
	WorkspaceFolders []*WorkspaceFolder  `json:"workspaceFolders,omitempty"`
}

type InitializedParams

type InitializedParams struct {
	None bool `json:"none"`
}

type JsonCodec

type JsonCodec struct {
	OnNotificationMessage   func(*NotificationMessage)
	OnIOReadError           func(error)
	OnUnexpectedServerReply func(*Response)
	// contains filtered or unexported fields
}

Implements rpc.ClientCodec

func NewJsonCodec

func NewJsonCodec(rwc io.ReadWriteCloser) *JsonCodec

Needs a call to ReadLoop() to start reading.

func (*JsonCodec) Close

func (c *JsonCodec) Close() error

func (*JsonCodec) ReadLoop

func (c *JsonCodec) ReadLoop()

func (*JsonCodec) ReadResponseBody

func (c *JsonCodec) ReadResponseBody(reply interface{}) error

func (*JsonCodec) ReadResponseHeader

func (c *JsonCodec) ReadResponseHeader(resp *rpc.Response) error

Sets response.Seq to have ReadResponseBody be called with the correct reply variable. i

func (*JsonCodec) WriteRequest

func (c *JsonCodec) WriteRequest(req *rpc.Request, data interface{}) error

type LangInstance

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

func NewLangInstance

func NewLangInstance(lang *LangManager) *LangInstance

type LangManager

type LangManager struct {
	Reg *Registration // accessed from editor
	// contains filtered or unexported fields
}

func NewLangManager

func NewLangManager(man *Manager, reg *Registration) *LangManager

func (*LangManager) Close

func (lang *LangManager) Close() error

func (*LangManager) ErrorAsync

func (lang *LangManager) ErrorAsync(err error)

func (*LangManager) WrapError

func (lang *LangManager) WrapError(err error) error

type Location

type Location struct {
	Uri   string `json:"uri,omitempty"`
	Range *Range `json:"range,omitempty"`
}

type Manager

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

Notes: - Manager manages LangManagers - LangManager has a Registration and handles a LangInstance - Client handles client connection to the lsp server - ServerWrap, if used, runs the lsp server process

func NewManager

func NewManager(asyncErrFn func(error)) *Manager

func (*Manager) Close

func (man *Manager) Close() error

func (*Manager) LangManager

func (man *Manager) LangManager(filename string) (*LangManager, error)

func (*Manager) Register

func (man *Manager) Register(reg *Registration) error

func (*Manager) TextDocumentCompletion

func (man *Manager) TextDocumentCompletion(ctx context.Context, filename string, rd iorw.Reader, offset int) (*CompletionList, error)

func (*Manager) TextDocumentCompletionDetailStrings

func (man *Manager) TextDocumentCompletionDetailStrings(ctx context.Context, filename string, rd iorw.Reader, offset int) ([]string, error)

func (*Manager) TextDocumentDefinition

func (man *Manager) TextDocumentDefinition(ctx context.Context, filename string, rd iorw.Reader, offset int) (string, *Range, error)

type NotificationMessage

type NotificationMessage struct {
	Method string      `json:"method,omitempty"`
	Params interface{} `json:"params,omitempty"`
}

type Position

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

func OffsetToPosition

func OffsetToPosition(rd iorw.Reader, offset int) (Position, error)

type PublishDiagnostics

type PublishDiagnostics struct {
	RelatedInformation bool `json:"relatedInformation"`
}

type Range

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

type Registration

type Registration struct {
	Language string
	Exts     []string
	Cmd      string
	Network  string   // {stdio, tcp(runs text/template on cmd)}
	Optional []string // optional extra fields
}

func NewRegistration

func NewRegistration(s string) (*Registration, error)

func (*Registration) HasOptional

func (reg *Registration) HasOptional(s string) bool

type RequestMessage

type RequestMessage struct {
	JsonRpc string      `json:"jsonrpc"`
	Id      int         `json:"id"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
}

type Response

type Response struct {
	ResponseMessage
	NotificationMessage
}

type ResponseError

type ResponseError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type ResponseMessage

type ResponseMessage struct {
	Id     int             `json:"id,omitempty"` // id can be zero on first msg
	Error  *ResponseError  `json:"error,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
}

type ServerWrap

type ServerWrap struct {
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

func NewServerWrapIO

func NewServerWrapIO(ctx context.Context, cmd string, stderr io.Writer, li *LangInstance) (*ServerWrap, io.ReadWriteCloser, error)

func NewServerWrapTCP

func NewServerWrapTCP(ctx context.Context, cmdTmpl string, li *LangInstance) (*ServerWrap, string, error)

type TextDocumentClientCapabilities

type TextDocumentClientCapabilities struct {
	PublishDiagnostics *PublishDiagnostics `json:"publishDiagnostics,omitempty"`
}

type TextDocumentContentChangeEvent

type TextDocumentContentChangeEvent struct {
	Range       Range  `json:"range,omitempty"`
	RangeLength int    `json:"rangeLength,omitempty"`
	Text        string `json:"text,omitempty"`
}

type TextDocumentIdentifier

type TextDocumentIdentifier struct {
	Uri string `json:"uri"`
}

type TextDocumentItem

type TextDocumentItem struct {
	Uri        string `json:"uri"`
	LanguageId string `json:"languageId,omitempty"`
	Version    int    `json:"version"`
	Text       string `json:"text"`
}

type TextDocumentPositionParams

type TextDocumentPositionParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Position     Position               `json:"position"`
}

type VersionedTextDocumentIdentifier

type VersionedTextDocumentIdentifier struct {
	TextDocumentIdentifier
	Version int `json:"version"`
}

type WorkspaceClientCapabilities

type WorkspaceClientCapabilities struct {
	WorkspaceFolders bool `json:"workspaceFolders"`
}

type WorkspaceFolder

type WorkspaceFolder struct {
	Uri  string `json:"uri"`
	Name string `json:"name"`
}

type WorkspaceFoldersChangeEvent

type WorkspaceFoldersChangeEvent struct {
	Added   []*WorkspaceFolder `json:"added"`
	Removed []*WorkspaceFolder `json:"removed"`
}

Jump to

Keyboard shortcuts

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