runtime

package module
v0.0.0-...-8a443e9 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

README

runtime

Documentation

Overview

Package runtime provides the wrap of neovim/go-client utilities.

Index

Constants

This section is empty.

Variables

View Source
var ErrNegativeRead = xerrors.New("runtime.Buffer.Grow: reader returned negative count from Read")

ErrNegativeRead same as bytes.errNegativeRead.

View Source
var ErrTooLarge = xerrors.New("runtime.Buffer.Grow: too large")

ErrTooLarge same as bytes.errNegativeRead.

The passed to panic if memory cannot be allocated to store data in a buffer.

Functions

func Chdir

func Chdir(n *nvim.Nvim, dir string) (func() error, error)

Chdir changes the vim current working directory. The returned function restores working directory to `getcwd()` result path.

func CursorLinePosition

func CursorLinePosition(n *nvim.Nvim) (line int64, err error)

CursorLinePosition returns the current cursor line position.

func EchoError

func EchoError(n *nvim.Nvim, format string, a ...interface{}) error

EchoError provides the nvim 'echoerr' command use WriteOut API.

func EchoMsg

func EchoMsg(n *nvim.Nvim, format string, a ...interface{}) error

EchoMsg provides the nvim 'echomsg' command use WriteOut API.

func EchoWarn

func EchoWarn(n *nvim.Nvim, format string, a ...interface{}) error

EchoWarn show warning message use 'echo' command.

func IsBufferLoaded

func IsBufferLoaded(n *nvim.Nvim, buffer nvim.Buffer) bool

IsBufferLoaded reports whether the buffer is valid and loaded.

func IsBufferValid

func IsBufferValid(n *nvim.Nvim, buffer nvim.Buffer) bool

IsBufferValid reports whether the buffer is valid.

func IsTabpageValid

func IsTabpageValid(n *nvim.Nvim, tabpage nvim.Tabpage) bool

IsTabpageValid reports whether the tabpage is valid.

func IsWindowValid

func IsWindowValid(n *nvim.Nvim, window nvim.Window) bool

IsWindowValid reports whether the window is valid.

func Notify

func Notify(n *nvim.Nvim, cID int, event string, args ...interface{}) error

Notify call the rpcrequest nvim function.

func NvimFromContext

func NvimFromContext(ctx context.Context) *nvim.Nvim

NvimFromContext expands the nvim.Nvim from context.

func NvimWithContext

func NvimWithContext(ctx context.Context, n *nvim.Nvim) context.Context

NvimWithContext returns the context with embedded nvim.Nvim.

func Request

func Request(n *nvim.Nvim, reply interface{}, cID int, method string, args ...interface{}) error

Request call the rpcrequest nvim function and returns the reply and error.

func ToBufferLines

func ToBufferLines(b []byte) [][]byte

ToBufferLines converts the byte slice to the 2D byte slice of Neovim buffer data.

func ToByteSlice

func ToByteSlice(b [][]byte) []byte

ToByteSlice converts the 2D buffer byte data to sigle byte slice.

func TsetNewChildProcess

func TsetNewChildProcess(tb TB) (n *nvim.Nvim, cleanup func())

TsetNewChildProcess returns the new nvim and cleanup function.

Useful for nvim API testing.

Types

type Buffer

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

Buffer represents a Neovim buffer.

func NewBuffer

func NewBuffer(n *nvim.Nvim, buffer nvim.Buffer, initialize bool) *Buffer

NewBuffer return the new Buffer.

func NewBufferFromLines

func NewBufferFromLines(n *nvim.Nvim, buffer nvim.Buffer, lines []byte) *Buffer

NewBufferFromLines creates new Buffer from lines and returns Buffer.

func NewSizedBuffer

func NewSizedBuffer(n *nvim.Nvim, buffer nvim.Buffer, size int, initialize bool) (b *Buffer)

NewSizedBuffer return the new Buffer with grow buf to size length.

func (*Buffer) Buffer

func (b *Buffer) Buffer() nvim.Buffer

Buffer returns the current nvim.Buffer.

func (*Buffer) BufferLines

func (b *Buffer) BufferLines(start, end int) (data [][]byte, err error)

BufferLines gets the current buffer lines and set to b.buf, and returns the buffer lines.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes mimics bytes.Buffer.Bytes().

Bytes returns a slice of length b.Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like Read, Write, Reset, or Truncate). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads.

func (*Buffer) Cap

func (b *Buffer) Cap() int

Cap mimics bytes.Buffer.Cap().

Cap returns the capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.

func (*Buffer) Close

func (b *Buffer) Close() (err error)

Close implements io.Closer.

Close unload buffer and delete it from the buffer list.

func (*Buffer) Grow

func (b *Buffer) Grow(n int)

Grow mimics bytes.Buffer.Grow().

Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with ErrTooLarge.

func (*Buffer) Len

func (b *Buffer) Len() int

Len mimics bytes.Buffer.Len().

Len returns the number of bytes of the unread portion of the buffer.

func (*Buffer) Name

func (b *Buffer) Name() string

Name returns the buffer name.

func (*Buffer) Option

func (b *Buffer) Option(name string) (result interface{}, err error)

Option returns the name buffer option.

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (n int, err error)

Read implements io.Reader.

Read returns a reader for the specified buffer. If b = 0, then the current buffer is used.

func (*Buffer) ReadFrom

func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements io.ReaderFrom.

ReadFrom reads data from r until EOF and appends it to the buffer, growing the buffer as needed. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. If the buffer becomes too large, ReadFrom will panic with ErrNegativeRead.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset mimics bytes.Buffer.Reset().

Reset resets the Neovim buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as Truncate(0).

func (*Buffer) SetAutocmd

func (b *Buffer) SetAutocmd(events []string, command string, once bool) (err error)

SetAutocmd sets buffer local autocmd.

:help autocmd-buffer-local

func (*Buffer) SetBufferLines

func (b *Buffer) SetBufferLines(start, end int, replacement []byte) (err error)

SetBufferLines sets the replacement to current buffer.

func (*Buffer) SetOptions

func (b *Buffer) SetOptions(options map[string]interface{}) (err error)

SetOptions sets the buffer options with atomic call.

func (*Buffer) SetVar

func (b *Buffer) SetVar(name string, value interface{}) (err error)

SetVar sets the name buffer local option to value.

func (*Buffer) String

func (b *Buffer) String() string

String mimics bytes.Buffer.String().

String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "<nil>".

To build strings more efficiently, see the strings.Builder type.

func (*Buffer) Truncate

func (b *Buffer) Truncate(n int)

Truncate mimics bytes.Buffer.Truncate().

Truncate discards all but the first n unread bytes from the Neovim buffer but continues to use the same allocated storage.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write implements io.Writer.

Write appends the contents of p to the Neovim buffer.

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string) (n int, err error)

WriteString implements io.StringWriter.

WriteString appends the contents of s to the Neovim buffer.

type OpenWindowOption

type OpenWindowOption struct {
	Relative  string      `msgpack:"relative"`
	Anchar    string      `msgpack:"anchar"`
	Width     int64       `msgpack:"width"`
	Height    int64       `msgpack:"height"`
	Row       int64       `msgpack:"row"`
	Col       int64       `msgpack:"col"`
	Win       nvim.Window `msgpack:"win,omitempty"`
	Focusable bool        `msgpack:"focusable"`
	External  bool        `msgpack:"external,omitempty"`
}

OpenWindowOption represents a OpenWindow options.

type Sign

type Sign struct {
	Name     string
	Text     string
	Texthl   string
	Linehl   string
	LastID   int
	LastLine int
	LastFile string
	// contains filtered or unexported fields
}

Sign represents a Neovim sign.

func NewSign

func NewSign(n *nvim.Nvim, name, text, texthl, linehl string) (*Sign, error)

NewSign define new sign and return the new Sign.

func (*Sign) Place

func (s *Sign) Place(ctx context.Context, id, line int, file string, clearLastSign bool) (err error)

Place places the sign to any file.

func (*Sign) Unplace

func (s *Sign) Unplace(ctx context.Context, id int, file string) (err error)

Unplace unplace the sign.

func (*Sign) UnplaceAll

func (s *Sign) UnplaceAll(ctx context.Context, file string) (err error)

UnplaceAll unplace all signs.

type TB

type TB interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Name() string
	Skip(args ...interface{})
	SkipNow()
	Skipf(format string, args ...interface{})
	Skipped() bool
	Helper()
}

TB is the interface common to *testing.T and *testing.B.

for avoid import "testing" package into compiled binary.

type Tabpage

type Tabpage struct {
	nvim.Tabpage
}

Tabpage represents a Neovim tabpage context.

type Window

type Window struct {
	nvim.Window

	Buffer *Buffer
	// contains filtered or unexported fields
}

Window represents a Neovim window context.

func OpenWindow

func OpenWindow(n *nvim.Nvim, b nvim.Buffer, enter bool, opts *OpenWindowOption) (win *Window, err error)

OpenWindow opens the float window and sets scratch buffer to the window.

func OpenWindowWithBuffer

func OpenWindowWithBuffer(n *nvim.Nvim, b nvim.Buffer, buffer *Buffer, enter bool, opts *OpenWindowOption) (win *Window, err error)

OpenWindowWithBuffer opens the float window and sets buffer to the window.

func (*Window) SetOptions

func (w *Window) SetOptions(options map[string]interface{}) (err error)

SetOptions sets the window options with atomic call.

type WindowLine

type WindowLine struct {
	Start int64
	End   int64
}

WindowLine represents a current cursor line.

func CurrentWindowLine

func CurrentWindowLine(n *nvim.Nvim) (wl WindowLine, err error)

CurrentWindowLine returns the first line and last line visible in current window.

Jump to

Keyboard shortcuts

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