vim

package module
v0.0.0-...-32a96bf Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2016 License: MIT Imports: 15 Imported by: 1

README ΒΆ

vim-go-client - Vim 8.0 client written in go

Travis Build Status Coverage Status Go Report Card LICENSE GoDoc

WIP

🐦 Author

haya14busa (https://github.com/haya14busa)

Documentation ΒΆ

Overview ΒΆ

Package vim provides Vim client and server implementations. You can start Vim as a server as a child process or connect to Vim, and communicate with it via TCP or stdin/stdout. :h channel.txt

Index ΒΆ

Examples ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var ErrExpr = errors.New("the evaluation fails or the result can't be encoded in JSON")

ErrExpr represents "expr" command error.

View Source
var ErrTimeOut = errors.New("time out")

ErrTimeOut represents time out error.

Functions ΒΆ

func NewChildClient ΒΆ

func NewChildClient(handler Handler, args []string) (*Client, *ChildCliCloser, error)

NewChildClient creates connected child process Vim client.

func NewReadWriter ΒΆ

func NewReadWriter(r io.Reader, w io.Writer) io.ReadWriter

NewReadWriter returns simple io.ReadWriter. bufio.ReadWriter has buffers and needs to be flushed., so we cannot use bufio.NewReadWriter() for Vim client which accept io.ReadWriter. ref: https://groups.google.com/forum/#!topic/golang-nuts/OJnnwlfsPCc

func SetLogger ΒΆ

func SetLogger(l *log.Logger)

SetLogger sets the logger that is used in go process. Call only from init() functions.

Types ΒΆ

type Body ΒΆ

type Body interface{}

Body represents Message body. e.g. {expr} of `:h ch_sendexpr()`

type ChildCliCloser ΒΆ

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

ChildCliCloser is closer of child Vim client process.

func (*ChildCliCloser) Close ΒΆ

func (c *ChildCliCloser) Close() error

Close closes child Vim client process.

type Client ΒΆ

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

Client represents Vim client.

func NewClient ΒΆ

func NewClient(rw io.ReadWriter, handler Handler) *Client

NewClient creates Vim client.

Example (Job) ΒΆ
package main

import (
	"os"

	vim "github.com/haya14busa/vim-go-client"
)

type echoHandler struct{}

func (h *echoHandler) Serve(cli *vim.Client, msg *vim.Message) {
	cli.Send(msg)
}

func main() {
	// see example/echo/ for working example.
	handler := &echoHandler{}
	cli := vim.NewClient(vim.NewReadWriter(os.Stdin, os.Stdout), handler)
	cli.Start()
}
Output:

func (*Client) Call ΒΆ

func (cli *Client) Call(funcname string, args ...interface{}) (Body, error)

Call runs command "call" (:h channel-commands).

func (*Client) Ex ΒΆ

func (cli *Client) Ex(cmd string) error

Ex runs command "ex" (:h channel-commands).

func (*Client) Expr ΒΆ

func (cli *Client) Expr(expr string) (Body, error)

Expr runs command "expr" (:h channel-commands).

func (*Client) Normal ΒΆ

func (cli *Client) Normal(ncmd string) error

Normal runs command "normal" (:h channel-commands).

func (*Client) Redraw ΒΆ

func (cli *Client) Redraw(force string) error

Redraw runs command "redraw" (:h channel-commands).

func (*Client) Send ΒΆ

func (cli *Client) Send(msg *Message) error

Send sends message to Vim.

func (*Client) Start ΒΆ

func (cli *Client) Start() error

Start starts to wait message from Vim.

func (*Client) Write ΒΆ

func (cli *Client) Write(p []byte) (n int, err error)

Write writes raw message to Vim.

type Handler ΒΆ

type Handler interface {
	Serve(*Client, *Message)
}

Handler represents go server handler to handle message from Vim.

type Message ΒΆ

type Message struct {
	MsgID int
	Body  Body
}

Message represents rpc message type of JSON channel. `:h channel-use`.

type Process ΒΆ

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

Process represents Vim server process.

func NewChildVimServer ΒΆ

func NewChildVimServer(addr string, args []string) (*Process, error)

NewChildVimServer creates Vim server process and connect to go-server by addr.

func (*Process) Close ΒΆ

func (p *Process) Close() error

Close closes Vim process.

type Server ΒΆ

type Server struct {
	Handler Handler // handler to invoke
}

Server represents go server.

func (*Server) Serve ΒΆ

func (srv *Server) Serve(l net.Listener) error

Serve starts go server.

Directories ΒΆ

Path Synopsis
_example

Jump to

Keyboard shortcuts

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