example

package
v0.0.0-...-f91850c Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2015 License: MIT Imports: 2 Imported by: 0

README

github.com/myitcv/neovim/example

A bare-bones example of a Neovim plugin written in Go

Writing a plugin currently involves a number of steps which will be automated with time:

  1. Defining the equivalent of Example (example.go), a type that implements neovim.Plugin
  2. Defining sync and async plugin methods, such as GetTwoNumbers and DoSomethingAsync
  3. Generating (by hand for now) wrappers around these types (gen_example.go)
  4. Generating (using msgp) MSGPACK wrappers around the wrappers (!) (gen_example_gen.go)
  5. Testing that this all works (example_test.go) with Neovim: go test
  6. Generating (by hand for now) the necessary bootstrap/wrappers to register these functions with Neovim

Clearly all the steps after step 2 should be automated in some fashion. See the TODO for a more up-to-date list of what remains to be done.

Installing and using the Example plugin

  1. mkdir -p $HOME/.nvim/plugins/go/
  2. go get -u github.com/myitcv/neovim/cmd/neovim-go-plugin-manager
  3. $GOPATH/bin/neovim-go-plugin-manager github.com/myitcv/neovim/example

Now launch nvim

nvim -u $GOPATH/src/github.com/myitcv/neovim/example/special.vimrc

and try:

:echo GetTwoNumbers(5)

The output should read:

[47, '42']

If you tail the equivalent of /tmp/neovim_go_plugin_host then you should also see output:

$ tail -f /tmp/neovim_go_plugin_host
2015/08/25 11:45:09 /tmp/neovim-go-plugin-manager_1440497199966172499/plugin_host.go:66: Successfully connected to Neovim
2015/08/25 11:45:09 /tmp/neovim-go-plugin-manager_1440497199966172499/plugin_host.go:81: Connecting *example.Example
2015/08/25 11:45:09 /tmp/neovim-go-plugin-manager_1440497199966172499/plugin_host.go:86: Successfully called Init on *example.Example

You can also call the async method DoSomethingAsync from nvim:

:call DoSomethingAsync("test_string")

This results in the following line being appended to the host log file:

2015/08/25 11:45:56 /tmp/neovim-go-plugin-manager_1440497199966172499/plugin_host.go:152: *example.ExampleGot an event: test_string

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoSomethingAsyncArgs

type DoSomethingAsyncArgs struct {
	Arg0 string
}

func (*DoSomethingAsyncArgs) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (DoSomethingAsyncArgs) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (DoSomethingAsyncArgs) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (DoSomethingAsyncArgs) Msgsize

func (z DoSomethingAsyncArgs) Msgsize() (s int)

func (*DoSomethingAsyncArgs) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type Example

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

func (*Example) AddDoSomethingAsyncChan

func (n *Example) AddDoSomethingAsyncChan(c chan string)

func (*Example) DoSomethingAsync

func (n *Example) DoSomethingAsync(o *neovim.MethodOptionParams, s string) error

an async method defines no return values

func (*Example) GetTwoNumbers

func (n *Example) GetTwoNumbers(o *neovim.MethodOptionParams, i int, e *MyEvalResult) (int, string, error, error)

a synchronous method that returns two numbers

func (*Example) Init

func (n *Example) Init(c *neovim.Client, l neovim.Logger) error

func (*Example) Shutdown

func (n *Example) Shutdown() error

type GetTwoNumbersArgs

type GetTwoNumbersArgs struct {
	Arg0 int64
}

func (*GetTwoNumbersArgs) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (GetTwoNumbersArgs) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (GetTwoNumbersArgs) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (GetTwoNumbersArgs) Msgsize

func (z GetTwoNumbersArgs) Msgsize() (s int)

func (*GetTwoNumbersArgs) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type GetTwoNumbersResults

type GetTwoNumbersResults struct {
	Ret0 int64
	Ret1 string
}

func (*GetTwoNumbersResults) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (GetTwoNumbersResults) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (GetTwoNumbersResults) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (GetTwoNumbersResults) Msgsize

func (z GetTwoNumbersResults) Msgsize() (s int)

func (*GetTwoNumbersResults) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type MyEvalResult

type MyEvalResult struct {
	S string
	I int
}

func (*MyEvalResult) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (MyEvalResult) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (MyEvalResult) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (MyEvalResult) Msgsize

func (z MyEvalResult) Msgsize() (s int)

func (*MyEvalResult) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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