myitcv / neovim

Go package for writing Neovim plugins (in Go!)
http://godoc.org/github.com/myitcv/neovim
MIT License
85 stars 4 forks source link

Failed with simple example #35

Closed srenatus closed 8 years ago

srenatus commented 8 years ago

Hi there. Trying to build a small helper with this, I failed miserably. The following code prints a client, but never reaches line 32. What could be wrong? Tried it with NVIM_LISTEN_ADDRESS=127.0.0.1:7777 and the respective changes, too, no success.

    addr := os.Getenv("NVIM_LISTEN_ADDRESS")
    if addr == "" {
        log.Fatal("NVIM_LISTEN_ADDRESS is not set")
    }

    sock, err := net.ResolveUnixAddr("unix", addr)
    if err != nil {
        log.Fatal(err)
    }

    c, err := neovim.NewUnixClient(neovim.NullInitMethod, "unix", nil, sock, nil)
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("got client: %s\n", c)

    b, err := c.GetCurrentBuffer()
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("got current buffer: %s\n", b)

Thanks a lot :smiley:

ghost commented 8 years ago

Call Run before calling GetCurrentBuffer.

srenatus commented 8 years ago

Oh dear. Thank you so much.