neovim: github.com/myitcv/neovim Index | Examples | Files | Directories

package neovim

import "github.com/myitcv/neovim"

go:generate msgp

Package neovim implements support for writing Neovim plugins in Go. Communication with Neovim is via MSGPACK:

https://github.com/msgpack/msgpack/blob/master/spec.md

All Neovim API methods are supported. In addition there is support for handling synchronous method calls or asynchronous notifications from Neovim by registering handlers in your plugin. See the MSGPACK RPC spec for further details on these two types of callback:

https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md

Via a plugin manifest (details to follow) your plugin can bind these handlers to either Autocmds, Functions or Commands in Neovim.

Status

This project is still in alpha.

Example Plugin

For a complete example, see the example.Example plugin http://godoc.org/github.com/myitcv/neovim/example

Writing plugins

Plugins implement the Plugin interface. Plugins are initialised with a Client that is passed to a plugin via the Init method they implement. The Client is used to communicate with a Neovim instance.

Concurrency

A single Client may safely be used by multiple goroutines. Calls to API methods are blocking by design.

Compatibility

There are currently no checks to verify a connected Neovim instance exposes the same API against which the neovim package was generated. This is future work (and probably needs some work on the Neovim side).

See also

The tool for generating the API The Neovim Go plugin manager The code generator used by plugin writers

Errors

Errors returned by this package are created using errors at http://godoc.org/github.com/juju/errors. Hence errors may be inspected using functions like errors.Details for example:

_, err := client.GetCurrentBuffer()
if err != nil {
	log.Fatalf("Could not get current buffer: %v", errors.Details(err))
}

Index

Examples

Package Files

api_types.go api_types_gen.go encode_decode.go gen_client_api.go gotemplate_asyncProvSyncMap.go gotemplate_respSyncMap.go gotemplate_syncProvSyncMap.go init_method.go neovim.go types.go

func NullInitMethod Uses

func NullInitMethod() error

type AsyncDecoder Uses

type AsyncDecoder interface {
    CallArgs
    AsyncRunner
}

type AsyncRunner Uses

type AsyncRunner interface {
    Run() error
}

type Buffer Uses

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

Buffer represents a Neovim Buffer

Multiple goroutines may invoke methods on a Buffer simultaneously

func (*Buffer) DelLine Uses

func (b *Buffer) DelLine(index int) error

DelLine waiting for documentation from Neovim

func (*Buffer) ExtensionType Uses

func (b *Buffer) ExtensionType() int8

func (*Buffer) GetLine Uses

func (b *Buffer) GetLine(index int) (string, error)

GetLine waiting for documentation from Neovim

func (*Buffer) GetLineSlice Uses

func (b *Buffer) GetLineSlice(start int, end int, includeStart bool, includeEnd bool) ([]string, error)

GetLineSlice waiting for documentation from Neovim

func (*Buffer) GetMark Uses

func (b *Buffer) GetMark(name string) ([]int, error)

GetMark waiting for documentation from Neovim

func (*Buffer) GetName Uses

func (b *Buffer) GetName() (string, error)

GetName waiting for documentation from Neovim

func (*Buffer) GetNumber Uses

func (b *Buffer) GetNumber() (int, error)

GetNumber waiting for documentation from Neovim

func (*Buffer) GetOption Uses

func (b *Buffer) GetOption(name string) (interface{}, error)

GetOption waiting for documentation from Neovim

func (*Buffer) GetVar Uses

func (b *Buffer) GetVar(name string) (interface{}, error)

GetVar waiting for documentation from Neovim

func (*Buffer) Insert Uses

func (b *Buffer) Insert(lnum int, lines []string) error

Insert waiting for documentation from Neovim

func (*Buffer) IsValid Uses

func (b *Buffer) IsValid() (bool, error)

IsValid waiting for documentation from Neovim

func (*Buffer) Len Uses

func (b *Buffer) Len() int

func (*Buffer) LineCount Uses

func (b *Buffer) LineCount() (int, error)

LineCount waiting for documentation from Neovim

func (*Buffer) MarshalBinaryTo Uses

func (b *Buffer) MarshalBinaryTo(buf []byte) error

func (*Buffer) SetLine Uses

func (b *Buffer) SetLine(index int, line string) error

SetLine waiting for documentation from Neovim

func (*Buffer) SetLineSlice Uses

func (b *Buffer) SetLineSlice(start int, end int, includeStart bool, includeEnd bool, replacement []string) error

SetLineSlice waiting for documentation from Neovim

func (*Buffer) SetName Uses

func (b *Buffer) SetName(name string) error

SetName waiting for documentation from Neovim

func (*Buffer) SetOption Uses

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

SetOption waiting for documentation from Neovim

func (*Buffer) SetVar Uses

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

SetVar waiting for documentation from Neovim

func (*Buffer) UnmarshalBinary Uses

func (b *Buffer) UnmarshalBinary(buf []byte) error

type CallArgs Uses

type CallArgs interface {
    Eval() msgp.Decodable
    Params() *MethodOptionParams
    Args() msgp.Decodable
}

type ChannelID Uses

type ChannelID uint8

type Client Uses

type Client struct {

    // PanicOnError can be set to have the Client panic when an error would
    // otherwise have been returned via an API method. Note: any attempt to
    // change this option during concurrent use of the Client will be racey.
    // This is useful for debugging.
    PanicOnError bool
    KillChannel  chan struct{}

    // TODO remove this
    HostName string
    // contains filtered or unexported fields
}

A Client represents a connection to a single Neovim instance

func NewClient Uses

func NewClient(im InitMethod, c io.ReadWriteCloser, log Logger) (*Client, error)

NewClient creates a new Client

func NewCmdClient Uses

func NewCmdClient(im InitMethod, c *exec.Cmd, log Logger) (*Client, error)

NewCmdClient creates a new Client that is linked via stdin/stdout to the supplied exec.Cmd, which is assumed to launch Neovim. The Neovim flag --embed is added if it is missing, and the exec.Cmd is started as part of creating the client. Calling Close() will close stdin on the embedded Neovim instance, thereby ending the process

func NewUnixClient Uses

func NewUnixClient(im InitMethod, _net string, laddr, raddr *net.UnixAddr, log Logger) (*Client, error)

NewUnixClient is a convenience method for creating a new *Client. Method signature matches that of net.DialUnix

func (*Client) CallFunction Uses

func (c *Client) CallFunction(fname string, args []interface{}) (interface{}, error)

CallFunction waiting for documentation from Neovim

func (*Client) ChangeDirectory Uses

func (c *Client) ChangeDirectory(dir string) error

ChangeDirectory waiting for documentation from Neovim

func (*Client) Close Uses

func (c *Client) Close() error

Close cleanly kills the client connection to Neovim

func (*Client) Command Uses

func (c *Client) Command(str string) error

Command waiting for documentation from Neovim

func (*Client) CommandOutput Uses

func (c *Client) CommandOutput(str string) (string, error)

CommandOutput waiting for documentation from Neovim

func (*Client) DelCurrentLine Uses

func (c *Client) DelCurrentLine() error

DelCurrentLine waiting for documentation from Neovim

func (*Client) ErrWrite Uses

func (c *Client) ErrWrite(str string) error

ErrWrite waiting for documentation from Neovim

func (*Client) Eval Uses

func (c *Client) Eval(str string) (interface{}, error)

Eval waiting for documentation from Neovim

func (*Client) Feedkeys Uses

func (c *Client) Feedkeys(keys string, mode string, escapeCsi bool) error

Feedkeys waiting for documentation from Neovim

func (*Client) GetAPIInfo Uses

func (c *Client) GetAPIInfo() (ChannelID, *apidef.API, error)

func (*Client) GetApiInfo Uses

func (c *Client) GetApiInfo() ([]interface{}, error)

GetApiInfo waiting for documentation from Neovim

func (*Client) GetBuffers Uses

func (c *Client) GetBuffers() ([]Buffer, error)

GetBuffers waiting for documentation from Neovim

func (*Client) GetColorMap Uses

func (c *Client) GetColorMap() (map[string]interface{}, error)

GetColorMap waiting for documentation from Neovim

func (*Client) GetCurrentBuffer Uses

func (c *Client) GetCurrentBuffer() (Buffer, error)

GetCurrentBuffer waiting for documentation from Neovim

Code:

cmd := exec.Command(os.Getenv("NEOVIM_BIN"), "-u", "/dev/null")
cmd.Dir = "/tmp"

client, err := neovim.NewCmdClient(neovim.NullInitMethod, cmd, nil)
if err != nil {
    log.Fatalf("Could not create new client: %v", errors.Details(err))
}
client.Run()

b, err := client.GetCurrentBuffer()
if err != nil {
    log.Fatalf("Could not get current buffer: %v", errors.Details(err))
}
n, err := b.GetName()
if err != nil {
    log.Fatalf("Could not get name for buffer %v: %v", b, errors.Details(err))
}
fmt.Printf("Current buffer is: %v %v\n", b.ID, n)

err = client.Close()
if err != nil {
    log.Fatalf("Could not close client: %v\n", err)
}

Output:

Current buffer is: 2

func (*Client) GetCurrentLine Uses

func (c *Client) GetCurrentLine() (string, error)

GetCurrentLine waiting for documentation from Neovim

func (*Client) GetCurrentTabpage Uses

func (c *Client) GetCurrentTabpage() (Tabpage, error)

GetCurrentTabpage waiting for documentation from Neovim

func (*Client) GetCurrentWindow Uses

func (c *Client) GetCurrentWindow() (Window, error)

GetCurrentWindow waiting for documentation from Neovim

func (*Client) GetOption Uses

func (c *Client) GetOption(name string) (interface{}, error)

GetOption waiting for documentation from Neovim

func (*Client) GetTabpages Uses

func (c *Client) GetTabpages() ([]Tabpage, error)

GetTabpages waiting for documentation from Neovim

func (*Client) GetVar Uses

func (c *Client) GetVar(name string) (interface{}, error)

GetVar waiting for documentation from Neovim

func (*Client) GetVvar Uses

func (c *Client) GetVvar(name string) (interface{}, error)

GetVvar waiting for documentation from Neovim

func (*Client) GetWindows Uses

func (c *Client) GetWindows() ([]Window, error)

GetWindows waiting for documentation from Neovim

func (*Client) Input Uses

func (c *Client) Input(keys string) (int, error)

Input waiting for documentation from Neovim

func (*Client) ListRuntimePaths Uses

func (c *Client) ListRuntimePaths() ([]string, error)

ListRuntimePaths waiting for documentation from Neovim

func (*Client) NameToColor Uses

func (c *Client) NameToColor(name string) (int, error)

NameToColor waiting for documentation from Neovim

func (*Client) OutWrite Uses

func (c *Client) OutWrite(str string) error

OutWrite waiting for documentation from Neovim

func (*Client) RegisterAsyncFunction Uses

func (c *Client) RegisterAsyncFunction(m string, d NewAsyncDecoder, rangeBased bool, eval bool) error

func (*Client) RegisterAsyncRequestHandler Uses

func (c *Client) RegisterAsyncRequestHandler(m string, d NewAsyncDecoder, o *MethodOptions) error

func (*Client) RegisterSyncFunction Uses

func (c *Client) RegisterSyncFunction(m string, d NewSyncDecoder, rangeBased bool, eval bool) error

func (*Client) RegisterSyncRequestHandler Uses

func (c *Client) RegisterSyncRequestHandler(m string, d NewSyncDecoder, o *MethodOptions) error

func (*Client) ReplaceTermcodes Uses

func (c *Client) ReplaceTermcodes(str string, fromPart bool, doLt bool, special bool) (string, error)

ReplaceTermcodes waiting for documentation from Neovim

func (*Client) ReportError Uses

func (c *Client) ReportError(str string) error

ReportError waiting for documentation from Neovim

func (*Client) Run Uses

func (c *Client) Run()

func (*Client) SetCurrentBuffer Uses

func (c *Client) SetCurrentBuffer(buffer Buffer) error

SetCurrentBuffer waiting for documentation from Neovim

func (*Client) SetCurrentLine Uses

func (c *Client) SetCurrentLine(line string) error

SetCurrentLine waiting for documentation from Neovim

func (*Client) SetCurrentTabpage Uses

func (c *Client) SetCurrentTabpage(tabpage Tabpage) error

SetCurrentTabpage waiting for documentation from Neovim

func (*Client) SetCurrentWindow Uses

func (c *Client) SetCurrentWindow(window Window) error

SetCurrentWindow waiting for documentation from Neovim

func (*Client) SetOption Uses

func (c *Client) SetOption(name string, value interface{}) error

SetOption waiting for documentation from Neovim

func (*Client) SetVar Uses

func (c *Client) SetVar(name string, value interface{}) (interface{}, error)

SetVar waiting for documentation from Neovim

func (*Client) Strwidth Uses

func (c *Client) Strwidth(str string) (int, error)

Strwidth waiting for documentation from Neovim

func (*Client) Subscribe Uses

func (c *Client) Subscribe(event string) error

Subscribe waiting for documentation from Neovim

func (*Client) Unsubscribe Uses

func (c *Client) Unsubscribe(event string) error

Unsubscribe waiting for documentation from Neovim

type Decoder Uses

type Decoder interface {
    DecodeMsg(*msgp.Reader) error
}

Use for async notifications Here the error would simply be reported to the log (because there is nothing to return)

type Encoder Uses

type Encoder interface {
    EncodeMsg(*msgp.Writer) error
}

type InitMethod Uses

type InitMethod func() error

type InitMethodArgs Uses

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

func (*InitMethodArgs) DecodeMsg Uses

func (z *InitMethodArgs) DecodeMsg(dc *msgp.Reader) (err error)

type InitMethodRetVals Uses

type InitMethodRetVals struct {
    InitMethod
}

func (*InitMethodRetVals) EncodeMsg Uses

func (z *InitMethodRetVals) EncodeMsg(en *msgp.Writer) (err error)

type InitMethodWrapper Uses

type InitMethodWrapper struct {
    *Client
    InitMethod
    // contains filtered or unexported fields
}

func (*InitMethodWrapper) Args Uses

func (i *InitMethodWrapper) Args() msgp.Decodable

func (*InitMethodWrapper) Eval Uses

func (i *InitMethodWrapper) Eval() msgp.Decodable

func (*InitMethodWrapper) Params Uses

func (i *InitMethodWrapper) Params() *MethodOptionParams

func (*InitMethodWrapper) Results Uses

func (i *InitMethodWrapper) Results() msgp.Encodable

func (*InitMethodWrapper) Run Uses

func (i *InitMethodWrapper) Run() (error, error)

type Logger Uses

type Logger interface {
    Fatal(v ...interface{})
    Fatalf(format string, v ...interface{})
    Fatalln(v ...interface{})
    Flags() int
    Output(calldepth int, s string) error
    Panic(v ...interface{})
    Panicf(format string, v ...interface{})
    Panicln(v ...interface{})
    Prefix() string
    Print(v ...interface{})
    Printf(format string, v ...interface{})
    Println(v ...interface{})
    SetFlags(flag int)
    SetPrefix(prefix string)
}

Logger is a local definition of the inteface effectively exposed by http://godoc.org/log

type MethodOptionParams Uses

type MethodOptionParams struct {
    Range *Range
}

func (*MethodOptionParams) DecodeParams Uses

func (m *MethodOptionParams) DecodeParams(o *MethodOptions, reader *msgp.Reader) error

type MethodOptions Uses

type MethodOptions struct {
    Type  MethodType
    Range bool
    Eval  bool
}

func (*MethodOptions) ArgsLength Uses

func (m *MethodOptions) ArgsLength() (res uint32)

type MethodType Uses

type MethodType uint
const (
    FUNCTION MethodType = iota
    COMMAND
    AUTOCOMMAND
)

type NewAsyncDecoder Uses

type NewAsyncDecoder func() AsyncDecoder

type NewAsyncDecoderOptions Uses

type NewAsyncDecoderOptions struct {
    NewAsyncDecoder
    *MethodOptions
}

type NewSyncDecoder Uses

type NewSyncDecoder func() SyncDecoder

type NewSyncDecoderOptions Uses

type NewSyncDecoderOptions struct {
    NewSyncDecoder
    *MethodOptions
}

type NilDeocdable Uses

type NilDeocdable struct{}

func (*NilDeocdable) DecodeMsg Uses

func (n *NilDeocdable) DecodeMsg(r *msgp.Reader) error

type Plugin Uses

type Plugin interface {
    Init(*Client, Logger) error
    Shutdown() error
}

Plugin is the interface implemented by writers of Neovim plugins using the neovim package

type Range Uses

type Range struct {
    StartLine, EndLine int
}

msgp:tuple Range

func (*Range) DecodeMsg Uses

func (z *Range) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Range) EncodeMsg Uses

func (z Range) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Range) MarshalMsg Uses

func (z Range) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Range) Msgsize Uses

func (z Range) Msgsize() (s int)

func (*Range) UnmarshalMsg Uses

func (z *Range) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type RequestHandler Uses

type RequestHandler func([]interface{}) ([]interface{}, error)

RequestHandler is the type signature of callback handlers used in RegisterRequestHandler

type StdWrapper Uses

type StdWrapper struct {
    Stdin  io.WriteCloser
    Stdout io.ReadCloser
}

StdWrapper is a wrapper around two io.WriterCloser and io.ReadCloser instances that exposes itself as an io.ReadWriteCloser. Typically used with os.Stdin and os.Stdout or their pipe equivalents

func (*StdWrapper) Close Uses

func (s *StdWrapper) Close() error

func (*StdWrapper) Read Uses

func (s *StdWrapper) Read(p []byte) (n int, err error)

func (*StdWrapper) Write Uses

func (s *StdWrapper) Write(p []byte) (n int, err error)

type SyncDecoder Uses

type SyncDecoder interface {
    CallArgs
    SyncRunner
    Results() msgp.Encodable
}

type SyncRunner Uses

type SyncRunner interface {
    Run() (error, error)
}

type Tabpage Uses

type Tabpage struct {
    ID uint8
    // contains filtered or unexported fields
}

Tabpage represents a Neovim Tabpage

Multiple goroutines may invoke methods on a Tabpage simultaneously

func (*Tabpage) ExtensionType Uses

func (b *Tabpage) ExtensionType() int8

func (*Tabpage) GetVar Uses

func (t *Tabpage) GetVar(name string) (interface{}, error)

GetVar waiting for documentation from Neovim

func (*Tabpage) GetWindow Uses

func (t *Tabpage) GetWindow() (Window, error)

GetWindow waiting for documentation from Neovim

func (*Tabpage) GetWindows Uses

func (t *Tabpage) GetWindows() ([]Window, error)

GetWindows waiting for documentation from Neovim

func (*Tabpage) IsValid Uses

func (t *Tabpage) IsValid() (bool, error)

IsValid waiting for documentation from Neovim

func (*Tabpage) Len Uses

func (b *Tabpage) Len() int

func (*Tabpage) MarshalBinaryTo Uses

func (b *Tabpage) MarshalBinaryTo(buf []byte) error

func (*Tabpage) SetVar Uses

func (t *Tabpage) SetVar(name string, value interface{}) (interface{}, error)

SetVar waiting for documentation from Neovim

func (*Tabpage) UnmarshalBinary Uses

func (b *Tabpage) UnmarshalBinary(buf []byte) error

type Window Uses

type Window struct {
    ID uint8
    // contains filtered or unexported fields
}

Window represents a Neovim Window

Multiple goroutines may invoke methods on a Window simultaneously

func (*Window) ExtensionType Uses

func (b *Window) ExtensionType() int8

func (*Window) GetBuffer Uses

func (w *Window) GetBuffer() (Buffer, error)

GetBuffer waiting for documentation from Neovim

func (*Window) GetCursor Uses

func (w *Window) GetCursor() ([]int, error)

GetCursor waiting for documentation from Neovim

func (*Window) GetHeight Uses

func (w *Window) GetHeight() (int, error)

GetHeight waiting for documentation from Neovim

func (*Window) GetOption Uses

func (w *Window) GetOption(name string) (interface{}, error)

GetOption waiting for documentation from Neovim

func (*Window) GetPosition Uses

func (w *Window) GetPosition() ([]int, error)

GetPosition waiting for documentation from Neovim

func (*Window) GetTabpage Uses

func (w *Window) GetTabpage() (Tabpage, error)

GetTabpage waiting for documentation from Neovim

func (*Window) GetVar Uses

func (w *Window) GetVar(name string) (interface{}, error)

GetVar waiting for documentation from Neovim

func (*Window) GetWidth Uses

func (w *Window) GetWidth() (int, error)

GetWidth waiting for documentation from Neovim

func (*Window) IsValid Uses

func (w *Window) IsValid() (bool, error)

IsValid waiting for documentation from Neovim

func (*Window) Len Uses

func (b *Window) Len() int

func (*Window) MarshalBinaryTo Uses

func (b *Window) MarshalBinaryTo(buf []byte) error

func (*Window) SetCursor Uses

func (w *Window) SetCursor(pos []int) error

SetCursor waiting for documentation from Neovim

func (*Window) SetHeight Uses

func (w *Window) SetHeight(height int) error

SetHeight waiting for documentation from Neovim

func (*Window) SetOption Uses

func (w *Window) SetOption(name string, value interface{}) error

SetOption waiting for documentation from Neovim

func (*Window) SetVar Uses

func (w *Window) SetVar(name string, value interface{}) (interface{}, error)

SetVar waiting for documentation from Neovim

func (*Window) SetWidth Uses

func (w *Window) SetWidth(width int) error

SetWidth waiting for documentation from Neovim

func (*Window) UnmarshalBinary Uses

func (b *Window) UnmarshalBinary(buf []byte) error

Directories

PathSynopsis
apidef
cmd/gen_neovim_api
cmd/neovim-go-plugin-manager
examplego:generate msgp

Package neovim imports 10 packages (graph) and is imported by 3 packages. Updated 2016-07-14. Refresh now. Tools for package owners.