func (c *Client) Close() error {
	c.lock.Lock()
	defer c.lock.Unlock()
	err := c.rw.Close()
	if err != nil {
		return c.panicOrReturn(errors.Annotatef(err, "Could not cleanly close client"))
	}
	return nil
}
Close cleanly kills the client connection to Neovim
package neovim
import (
	"io"
	_log "log"
	"net"
	"os"
	"os/exec"
	"sync/atomic"
	"github.com/juju/errors"
	"github.com/myitcv/neovim/apidef"
	"github.com/tinylib/msgp/msgp"
)
func NewUnixClient(im InitMethod, _net string, laddr, raddr *net.UnixAddr, log Logger) (*Client, error) {
	c, err := net.DialUnix(_net, laddr, raddr)
	if err != nil {
		return nil, errors.Annotatef(err, "could not establish connection to Neovim, _net %v, laddr %v, %v", _net, laddr, raddr)
	}
	return NewClient(im, c, log)
}
func NewCmdClient(im InitMethod, c *exec.Cmd, log Logger) (*Client, error) {
	stdin, err := c.StdinPipe()
	if err != nil {
		return nil, errors.Annotatef(err, "could not get a stdin pipe to embedded nvim")
	}
	stdout, err := c.StdoutPipe()
	if err != nil {
		return nil, errors.Annotatef(err, "could not get a stdout pipe to embedded nvim")
	}
	wrap := &StdWrapper{Stdin: stdin, Stdout: stdout}
	found := false
	for i := range c.Args {
		if c.Args[i] == "--embed" {
			found = true
		}
	}
	if !found {
		c.Args = append(c.Args, "--embed", "-N")
	}
	err = c.Start()
	if err != nil {
		return nil, errors.Annotatef(err, "could not start the embedded nvim")
	}
	return NewClient(im, wrap, log)
}
func NewClient(im InitMethod, c io.ReadWriteCloser, log Logger) (*Client, error) {
	if log == nil {
		log = _log.New(os.Stderr, "neovim ", _log.Llongfile|_log.Ldate|_log.Ltime)
	}
	res := &Client{rw: c}
	res.respMap = newRespSyncMap()
	res.syncProvMap = newSyncProvSyncMap()
	res.asyncProvMap = newAsyncProvSyncMap()
	res.dec = msgp.NewReader(c)
	res.enc = msgp.NewWriter(c)
	res.log = log
	res.KillChannel = make(chan struct{})
	err := res.syncProvMap.Put(_MethodInit, NewSyncDecoderOptions{NewSyncDecoder: func() SyncDecoder {
		res := &InitMethodWrapper{InitMethod: im, Client: res, args: &InitMethodArgs{}, results: &InitMethodRetVals{}}
		return res
	}, MethodOptions: &MethodOptions{Type: FUNCTION}})
	if err != nil {
		return nil, errors.Annotatef(err, "Could not add init method handler")
	}
	return res, nil
}
func (c *Client) Run() {
	go c.doListen()
}
func (c *Client) RegisterSyncFunction(m string, d NewSyncDecoder, rangeBased bool, eval bool) error {
	return c.RegisterSyncRequestHandler(m, d, &MethodOptions{
		Type:  FUNCTION,
		Range: rangeBased,
		Eval:  eval,
	})
}
func (c *Client) RegisterAsyncFunction(m string, d NewAsyncDecoder, rangeBased bool, eval bool) error {
	return c.RegisterAsyncRequestHandler(m, d, &MethodOptions{
		Type:  FUNCTION,
		Range: rangeBased,
		Eval:  eval,
	})
}
func (c *Client) RegisterSyncRequestHandler(m string, d NewSyncDecoder, o *MethodOptions) error {
	if m == _MethodInit {
		return errors.Errorf("Cannot register a provider with the protected method %v", _MethodInit)
	}
	err := c.syncProvMap.Put(m, NewSyncDecoderOptions{d, o})
	if err != nil {
		return errors.Annotatef(err, "Could not store RequestHanlder in provider map")
	}
	return nil
}
func (c *Client) RegisterAsyncRequestHandler(m string, d NewAsyncDecoder, o *MethodOptions) error {
	err := c.asyncProvMap.Put(m, NewAsyncDecoderOptions{d, o})
	if err != nil {
		return errors.Annotatef(err, "Could not store RequestHanlder in provider map")
	}
	return nil
}