language

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLILangServer

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

CLILangServer is an operation for constructing a language server from a command and connecting to its stdout and stdin. It is provided as sugar for plugins to more easily create language servers.

We provide this as an Action rather than a part of pkg/lsp to decouple the CLI language server logic from plugins.

func NewCLILangServer

func NewCLILangServer() *CLILangServer

func (*CLILangServer) FromCommand

func (c *CLILangServer) FromCommand(ctx context.Context, b input.Binder, cmd string, args ...string) (lsp.Conn, error)

func (*CLILangServer) Name

func (*CLILangServer) Run

func (*CLILangServer) Type

func (c *CLILangServer) Type(input.Operation)

type CapabilitiesHook

type CapabilitiesHook interface {
	input.Hook

	// Capabilities returns the capabilities that are added to vidar.
	Capabilities(context.Context) protocol.ClientCapabilities
}

CapabilitiesHook is an input.Hook that tells the LanguageServer plugin about language server capabilities the plugin that it is a part of adds to vidar.

type CommandConn

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

CommandConn implements a connection over STDIN/STDOUT on a command.

func (*CommandConn) Call

func (c *CommandConn) Call(ctx context.Context, method string, params, results any) error

func (*CommandConn) Close

func (c *CommandConn) Close(ctx context.Context) error

func (*CommandConn) Notify

func (c *CommandConn) Notify(ctx context.Context, method string, params any) error

func (*CommandConn) Reset

func (c *CommandConn) Reset(ctx context.Context) error

type ConnStore

type ConnStore interface {
	input.Action
	Conn(context.Context, input.Binder) (lsp.Conn, protocol.ServerCapabilities, error)
}

ConnStore is the action that needs to be bound to give us access to the connected language server.

type EditApplier

type EditApplier interface {
	input.Operation
	ApplyEdit(...input.Edit) input.Operation
	ApplyLineEdit(...input.LineEdit) input.Operation
}

EditApplier is the action that we use to apply changes to a document.

type FileBinder

type FileBinder interface {
	input.Binder
	Path(context.Context) (string, bool)
	State(context.Context) text.State
}

type FileContainer

type FileContainer interface {
	input.Binder
	Path(context.Context) (string, bool)
	State(context.Context) text.State
}

type FileManager

type FileManager interface {
	input.Action
	OpenFile(name, path string) input.Operation
	After(func(context.Context, input.Binder) error) input.Operation
}

FileManager is the action type that manages files.

type FileOpener

type FileOpener interface {
	input.Operation
	OpenFile(name, path string) input.Operation
	RetainFocus() input.Operation
	FileBinder(ctx context.Context, path string) (input.Binder, error)
}

type FileSaver

type FileSaver interface {
	input.Operation
	SaveFile() input.Operation
}

FileSaver is the action that we use to save the file (again) after applying formatting.

type Format

type Format struct{}

func NewFormat

func NewFormat() *Format

func (*Format) Name

func (f *Format) Name(context.Context) string

func (*Format) Run

func (f *Format) Run(ctx context.Context, b input.Binder) error

func (*Format) Type

func (f *Format) Type(input.Operation)

func (*Format) Valid

func (f *Format) Valid(ctx context.Context, b input.Binder) error

type FormatOnSave

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

func NewFormatOnSave

func NewFormatOnSave() *FormatOnSave

func (*FormatOnSave) FileSaving

func (f *FormatOnSave) FileSaving(ctx context.Context, b input.Binder) error

func (*FormatOnSave) Name

func (*FormatOnSave) OpNames

func (f *FormatOnSave) OpNames(context.Context) []string

func (*FormatOnSave) Type

func (f *FormatOnSave) Type(input.Hook)

func (*FormatOnSave) Valid

func (f *FormatOnSave) Valid(ctx context.Context, b input.Binder) error

type GotoDefinition

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

func NewGotoDefinition

func NewGotoDefinition(ctx context.Context) *GotoDefinition

func (*GotoDefinition) DefaultEvent

func (w *GotoDefinition) DefaultEvent() string

func (*GotoDefinition) Menu

func (*GotoDefinition) Name

func (*GotoDefinition) Op

func (*GotoDefinition) Type

func (w *GotoDefinition) Type(input.Command)

func (*GotoDefinition) Valid

func (w *GotoDefinition) Valid(ctx context.Context, b input.Binder) error

type Informer

type Informer interface {
	Box() input.Binder
	Info(string) input.Operation
	Warn(string) input.Operation
	Error(string) input.Operation
}

Informer represents an informational action. It is required to allow the language server to send requests to vidar.

type LSPSync

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

LSPSync implements the document synchronization required by the language server protocol. It hooks into core operations to keep documents in sync with the language server, if any.

func NewLSPSync

func NewLSPSync(c ui.Creator) *LSPSync

func (*LSPSync) FileClosed

func (s *LSPSync) FileClosed(ctx context.Context, b input.Binder)

func (*LSPSync) FileOpened

func (s *LSPSync) FileOpened(ctx context.Context, b input.Binder)

func (*LSPSync) Name

func (s *LSPSync) Name(context.Context) string

func (*LSPSync) OpNames

func (s *LSPSync) OpNames(context.Context) []string

func (*LSPSync) TextChanged

func (s *LSPSync) TextChanged(ctx context.Context, b input.Binder, hist ...struct {
	Before text.State
	Edit   input.Edit
})

func (*LSPSync) TextChangedOp

func (s *LSPSync) TextChangedOp(ctx context.Context, b input.Binder) input.Operation

func (*LSPSync) Type

func (s *LSPSync) Type(input.Hook)

func (*LSPSync) Valid

func (s *LSPSync) Valid(ctx context.Context, b input.Binder) (retErr error)

type Pather

type Pather interface {
	input.Binder
	Path(context.Context) (string, bool)
}

type Prompt

type Prompt interface {
	input.Action

	Prompt(...ui.Span) input.Operation
	Input(string) input.Operation
	Extra(...[]ui.Span) input.Operation
	Caller(input.Action) input.Operation
	Callback(func(context.Context, input.Binder, []ui.Span, string, [][]ui.Span) (input.Operation, error)) input.Operation
}

type Rename

type Rename struct{}

func NewRename

func NewRename() *Rename

func (*Rename) DefaultEvent

func (w *Rename) DefaultEvent() string

func (*Rename) Menu

func (r *Rename) Menu(context.Context) string

func (*Rename) Name

func (r *Rename) Name(context.Context) string

func (*Rename) Op

func (*Rename) Type

func (r *Rename) Type(input.Command)

func (*Rename) Valid

func (r *Rename) Valid(ctx context.Context, b input.Binder) (err error)

type RenameCapabilities

type RenameCapabilities struct{}

func NewRenameCaps

func NewRenameCaps() *RenameCapabilities

func (*RenameCapabilities) Capabilities

func (*RenameCapabilities) Name

func (*RenameCapabilities) OpNames

func (r *RenameCapabilities) OpNames(context.Context) []string

func (*RenameCapabilities) Type

func (r *RenameCapabilities) Type(input.Hook)

type SelectionSetter

type SelectionSetter interface {
	input.Action
	Select(caret.Selection, ...caret.Selection) input.Operation
}

SelectionSetter represents an operation that can move selections.

type SelectionStorer

type SelectionStorer interface {
	input.Binder

	Path(context.Context) (string, bool)

	Selections(context.Context) (caret.Selection, []caret.Selection)

	State(context.Context) text.State
}

SelectionStorer represents a type that tracks selections and understands positions within a file.

type ServerHook

type ServerHook interface {
	input.Hook

	// Initialize is called by the LanguageServer plugin when a new file is
	// opened. It is up to the individual language server Action to choose
	// whether to return an existing language server connection or create a new
	// one. Most of the time, at most one language server should be open per
	// workspace.
	//
	// A ServerHook should implement PickyAction and only bind if the
	// input.Binder is editing a file that the language server understands.
	//
	// If more than one ServerHook is bound to a given input.Binder, the first
	// one to Initialize without error will be used.
	Initialize(
		_ context.Context,
		b input.Binder,
		filePath string,
		caps protocol.ClientCapabilities,
	) (lsp.Conn, protocol.ServerCapabilities, error)
}

ServerHook is an input.Hook that can create connections to a language server.

type ServerOp

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

ServerOp is an op which records any open language server connection(s) for the current input.Binder for use by other input.Action types. The main reason to

func NewLSP

func NewLSP() *ServerOp

NewLSP returns a LanguageServer operation for registering langauge server connections for an open input.Binder.

func (*ServerOp) Conn

func (*ServerOp) Empty

func (*ServerOp) Name

func (s *ServerOp) Name(context.Context) string

func (*ServerOp) Run

func (s *ServerOp) Run(ctx context.Context, b input.Binder) error

func (*ServerOp) SetHook

func (s *ServerOp) SetHook(ctx context.Context, h input.Hook) error

func (*ServerOp) Setup

func (s *ServerOp) Setup(ctx context.Context, b input.Binder) error

func (*ServerOp) Type

func (s *ServerOp) Type(input.Operation)

func (*ServerOp) Valid

func (s *ServerOp) Valid(ctx context.Context, b input.Binder) error

Jump to

Keyboard shortcuts

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