func ChildProcessDir(dir string) ChildProcessOption {
	return ChildProcessOption{func(cpos *childProcessOptions) {
		cpos.dir = dir
	}}
}
ChildProcessDir specifies the working directory for the process. The current
working directory is used by default.
package nvim
import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"io"
	"log"
	"net"
	"os/exec"
	"reflect"
	"strings"
	"sync"
	"syscall"
	"time"
	"github.com/neovim/go-client/msgpack"
	"github.com/neovim/go-client/msgpack/rpc"
)
var embedProcAttr *syscall.SysProcAttr
type Nvim struct {
	ep *rpc.Endpoint
	cmd         *exec.Cmd
	serveCh     chan error
	channelID   int
	channelIDMu sync.Mutex
	readMu sync.Mutex
}
func (v *Nvim) Serve() error {
	v.readMu.Lock()
	defer v.readMu.Unlock()
	return v.ep.Serve()
}
func (v *Nvim) startServe() {
	v.serveCh = make(chan error, 1)
	go func() {
		v.serveCh <- v.Serve()
		close(v.serveCh)
	}()
}
func (v *Nvim) Close() error {
	if v.cmd != nil && v.cmd.Process != nil {
		t := time.AfterFunc(10*time.Second, func() { v.cmd.Process.Kill() })
		defer t.Stop()
	}
	err := v.ep.Close()
	if v.cmd != nil {
		v.readMu.Lock()
		defer v.readMu.Unlock()
		errWait := v.cmd.Wait()
		if err == nil {
			err = errWait
		}
	}
	if v.serveCh != nil {
		var errServe error
		select {
		case errServe = <-v.serveCh:
		case <-time.After(10 * time.Second):
			errServe = errors.New("nvim: Serve did not exit")
		}
		if err == nil {
			err = errServe
		}
	}
	return err
}
func New(r io.Reader, w io.Writer, c io.Closer, logf func(string, ...interface{})) (*Nvim, error) {
	ep, err := rpc.NewEndpoint(r, w, c, rpc.WithLogf(logf), withExtensions())
	if err != nil {
		return nil, err
	}
	return &Nvim{ep: ep}, nil
}
type ChildProcessOption struct {
	f func(*childProcessOptions)
}
type childProcessOptions struct {
	ctx     context.Context
	logf    func(string, ...interface{})
	command string
	dir     string
	args    []string
	env     []string
	serve   bool
}
func ChildProcessArgs(args ...string) ChildProcessOption {
	return ChildProcessOption{func(cpos *childProcessOptions) {
		cpos.args = args
	}}
}
func ChildProcessCommand(command string) ChildProcessOption {
	return ChildProcessOption{func(cpos *childProcessOptions) {
		cpos.command = command
	}}
}
func ChildProcessContext(ctx context.Context) ChildProcessOption {
	return ChildProcessOption{func(cpos *childProcessOptions) {
		cpos.ctx = ctx
	}}
}