Skip to content

Commit

Permalink
Prepare to deprecate plugins
Browse files Browse the repository at this point in the history
Neovim plans to deprecate remote plugins as described at
neovim/neovim#27949.

This commit removes references to remote plugins from all directories
except nvim/plugin.

We will wait for the completion of neovim/neovim#27949
before marking the `github.com/go-client/nvim/plugin` package as deprecated.
  • Loading branch information
garyburd committed May 13, 2024
1 parent 9b44fee commit ecea388
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 73 deletions.
65 changes: 1 addition & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,7 @@
[![Github Actions][Github Actions Badge]][Github Actions]
[![codecov.io][codecov-badge]][codecov]

Neovim/go-client is a [Neovim](https://neovim.io/) client and plugin host for [Go](https://golang.org/).

This example plugin adds the Hello command to Nvim.

```go
package main

import (
"strings"
"github.com/neovim/go-client/nvim/plugin"
)

func hello(args []string) (string, error) {
return "Hello " + strings.Join(args, " "), nil
}

func main() {
plugin.Main(func(p *plugin.Plugin) error {
p.HandleFunction(&plugin.FunctionOptions{Name: "Hello"}, hello)
return nil
})
}
```

Build the program with the [go tool](https://golang.org/cmd/go/) to an
executable named `hello`. Ensure that the executable is in a directory in
the `PATH` environment variable.

```go
// Use the `go build` command to generate an executable.
// To ensure this "hello" executable is on your path,
// you can move "hello" to your $GOPATH/bin directory
// or add the current directory to the `PATH` environment variable.
go build -o hello
```

Add the following plugin to Nvim:

```vim
if exists('g:loaded_hello')
finish
endif
let g:loaded_hello = 1
function! s:Requirehello(host) abort
" 'hello' is the binary created by compiling the program above.
return jobstart(['hello'], {'rpc': v:true})
endfunction
call remote#host#Register('hello', 'x', function('s:Requirehello'))
" The following lines are generated by running the program
" command line flag --manifest hello
call remote#host#RegisterPlugin('hello', '0', [
\ {'type': 'function', 'name': 'Hello', 'sync': 1, 'opts': {}},
\ ])
" vim:ts=4:sw=4:et
```

Start Nvim and run the following command:

```vim
:echo Hello('world')
```
Neovim/go-client is a [Neovim](https://neovim.io/) client for [Go](https://golang.org/).

Release
-------
Expand Down
5 changes: 1 addition & 4 deletions nvim/doc.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Package nvim implements a Nvim client.
//
// See the ./plugin package for additional functionality required for writing
// Nvim plugins.
//
// The Nvim type implements the client. To connect to a running instance of
// Nvim, create a *Nvim value using the Dial or NewChildProcess functions.
// Nvim, create a *Nvim value using the New, Dial or NewChildProcess functions.
// Call the Close() method to release the resources used by the client.
//
// Use the Batch type to execute a sequence of Nvim API calls atomically. The
Expand Down
5 changes: 0 additions & 5 deletions nvim/nvim.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ func (v *Nvim) ExitCode() int {
//
// The application must call Serve() to handle RPC requests and responses.
//
// New is a low-level function. Most applications should use NewChildProcess,
// Dial or the ./plugin package.
//
// :help rpc-connecting
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())
Expand Down Expand Up @@ -354,8 +351,6 @@ func Dial(address string, options ...DialOption) (*Nvim, error) {
// :help rpcrequest()
// :help rpcnotify()
//
// Plugin applications should use the Handler* methods in the ./plugin package
// to register handlers instead of this method.
func (v *Nvim) RegisterHandler(method string, fn interface{}) error {
var args []interface{}
t := reflect.TypeOf(fn)
Expand Down
74 changes: 74 additions & 0 deletions nvim/plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Status
------

This package will be deprecated when Neovim [removes the concept of
remote plugins](https://github.com/neovim/neovim/issues/27949).


Example
-------

This example plugin adds the Hello command to Nvim.

```go
package main

import (
"strings"
"github.com/neovim/go-client/nvim/plugin"
)

func hello(args []string) (string, error) {
return "Hello " + strings.Join(args, " "), nil
}

func main() {
plugin.Main(func(p *plugin.Plugin) error {
p.HandleFunction(&plugin.FunctionOptions{Name: "Hello"}, hello)
return nil
})
}
```

Build the program with the [go tool](https://golang.org/cmd/go/) to an
executable named `hello`. Ensure that the executable is in a directory in
the `PATH` environment variable.

```bash
// Use the `go build` command to generate an executable.
// To ensure this "hello" executable is on your path,
// you can move "hello" to your $GOPATH/bin directory
// or add the current directory to the `PATH` environment variable.
go build -o hello
```

Add the following plugin to Nvim:

```vim
if exists('g:loaded_hello')
finish
endif
let g:loaded_hello = 1
function! s:Requirehello(host) abort
" 'hello' is the binary created by compiling the program above.
return jobstart(['hello'], {'rpc': v:true})
endfunction
call remote#host#Register('hello', 'x', function('s:Requirehello'))
" The following lines are generated by running the program
" command line flag --manifest hello
call remote#host#RegisterPlugin('hello', '0', [
\ {'type': 'function', 'name': 'Hello', 'sync': 1, 'opts': {}},
\ ])
" vim:ts=4:sw=4:et
```

Start Nvim and run the following command:

```vim
:echo Hello('world')
```


0 comments on commit ecea388

Please sign in to comment.