Documentation ¶
Overview ¶
Package runtime provides the wrap of neovim/go-client utilities.
Index ¶
- Variables
- func Chdir(n *nvim.Nvim, dir string) (func() error, error)
- func CursorLinePosition(n *nvim.Nvim) (line int64, err error)
- func EchoError(n *nvim.Nvim, format string, a ...interface{}) error
- func EchoMsg(n *nvim.Nvim, format string, a ...interface{}) error
- func EchoWarn(n *nvim.Nvim, format string, a ...interface{}) error
- func IsBufferLoaded(n *nvim.Nvim, buffer nvim.Buffer) bool
- func IsBufferValid(n *nvim.Nvim, buffer nvim.Buffer) bool
- func IsTabpageValid(n *nvim.Nvim, tabpage nvim.Tabpage) bool
- func IsWindowValid(n *nvim.Nvim, window nvim.Window) bool
- func Notify(n *nvim.Nvim, cID int, event string, args ...interface{}) error
- func NvimFromContext(ctx context.Context) *nvim.Nvim
- func NvimWithContext(ctx context.Context, n *nvim.Nvim) context.Context
- func Request(n *nvim.Nvim, reply interface{}, cID int, method string, args ...interface{}) error
- func ToBufferLines(b []byte) [][]byte
- func ToByteSlice(b [][]byte) []byte
- func TsetNewChildProcess(tb TB) (n *nvim.Nvim, cleanup func())
- type Buffer
- func (b *Buffer) Buffer() nvim.Buffer
- func (b *Buffer) BufferLines(start, end int) (data [][]byte, err error)
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Close() (err error)
- func (b *Buffer) Grow(n int)
- func (b *Buffer) Len() int
- func (b *Buffer) Name() string
- func (b *Buffer) Option(name string) (result interface{}, err error)
- func (b *Buffer) Read(p []byte) (n int, err error)
- func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)
- func (b *Buffer) Reset()
- func (b *Buffer) SetAutocmd(events []string, command string, once bool) (err error)
- func (b *Buffer) SetBufferLines(start, end int, replacement []byte) (err error)
- func (b *Buffer) SetOptions(options map[string]interface{}) (err error)
- func (b *Buffer) SetVar(name string, value interface{}) (err error)
- func (b *Buffer) String() string
- func (b *Buffer) Truncate(n int)
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteString(s string) (n int, err error)
- type OpenWindowOption
- type Sign
- type TB
- type Tabpage
- type Window
- type WindowLine
Constants ¶
This section is empty.
Variables ¶
var ErrNegativeRead = xerrors.New("runtime.Buffer.Grow: reader returned negative count from Read")
ErrNegativeRead same as bytes.errNegativeRead.
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 ¶
Chdir changes the vim current working directory. The returned function restores working directory to `getcwd()` result path.
func CursorLinePosition ¶
CursorLinePosition returns the current cursor line position.
func IsBufferLoaded ¶
IsBufferLoaded reports whether the buffer is valid and loaded.
func IsBufferValid ¶
IsBufferValid reports whether the buffer is valid.
func IsTabpageValid ¶
IsTabpageValid reports whether the tabpage is valid.
func IsWindowValid ¶
IsWindowValid reports whether the window is valid.
func NvimFromContext ¶
NvimFromContext expands the nvim.Nvim from context.
func NvimWithContext ¶
NvimWithContext returns the context with embedded nvim.Nvim.
func ToBufferLines ¶
ToBufferLines converts the byte slice to the 2D byte slice of Neovim buffer data.
func ToByteSlice ¶
ToByteSlice converts the 2D buffer byte data to sigle byte slice.
func TsetNewChildProcess ¶
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 NewBufferFromLines ¶
NewBufferFromLines creates new Buffer from lines and returns Buffer.
func NewSizedBuffer ¶
NewSizedBuffer return the new Buffer with grow buf to size length.
func (*Buffer) BufferLines ¶
BufferLines gets the current buffer lines and set to b.buf, and returns the buffer lines.
func (*Buffer) Bytes ¶
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 ¶
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 ¶
Close implements io.Closer.
Close unload buffer and delete it from the buffer list.
func (*Buffer) Grow ¶
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 ¶
Len mimics bytes.Buffer.Len().
Len returns the number of bytes of the unread portion of the buffer.
func (*Buffer) Read ¶
Read implements io.Reader.
Read returns a reader for the specified buffer. If b = 0, then the current buffer is used.
func (*Buffer) ReadFrom ¶
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) SetBufferLines ¶
SetBufferLines sets the replacement to current buffer.
func (*Buffer) SetOptions ¶
SetOptions sets the buffer options with atomic call.
func (*Buffer) 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 ¶
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.
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 (*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.
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 Window ¶
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 ¶
SetOptions sets the window options with atomic call.
type WindowLine ¶
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.