Skip to content

Commit 2163acb

Browse files
committed
Prepare to deprecate support for remote plugins
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.
1 parent 1987893 commit 2163acb

File tree

4 files changed

+76
-73
lines changed

4 files changed

+76
-73
lines changed

README.md

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,7 @@
44
[![Github Actions][Github Actions Badge]][Github Actions]
55
[![codecov.io][codecov-badge]][codecov]
66

7-
Neovim/go-client is a [Neovim](https://neovim.io/) client and plugin host for [Go](https://golang.org/).
8-
9-
This example plugin adds the Hello command to Nvim.
10-
11-
```go
12-
package main
13-
14-
import (
15-
"strings"
16-
"github.com/neovim/go-client/nvim/plugin"
17-
)
18-
19-
func hello(args []string) (string, error) {
20-
return "Hello " + strings.Join(args, " "), nil
21-
}
22-
23-
func main() {
24-
plugin.Main(func(p *plugin.Plugin) error {
25-
p.HandleFunction(&plugin.FunctionOptions{Name: "Hello"}, hello)
26-
return nil
27-
})
28-
}
29-
```
30-
31-
Build the program with the [go tool](https://golang.org/cmd/go/) to an
32-
executable named `hello`. Ensure that the executable is in a directory in
33-
the `PATH` environment variable.
34-
35-
```go
36-
// Use the `go build` command to generate an executable.
37-
// To ensure this "hello" executable is on your path,
38-
// you can move "hello" to your $GOPATH/bin directory
39-
// or add the current directory to the `PATH` environment variable.
40-
go build -o hello
41-
```
42-
43-
Add the following plugin to Nvim:
44-
45-
```vim
46-
if exists('g:loaded_hello')
47-
finish
48-
endif
49-
let g:loaded_hello = 1
50-
51-
function! s:Requirehello(host) abort
52-
" 'hello' is the binary created by compiling the program above.
53-
return jobstart(['hello'], {'rpc': v:true})
54-
endfunction
55-
56-
call remote#host#Register('hello', 'x', function('s:Requirehello'))
57-
" The following lines are generated by running the program
58-
" command line flag --manifest hello
59-
call remote#host#RegisterPlugin('hello', '0', [
60-
\ {'type': 'function', 'name': 'Hello', 'sync': 1, 'opts': {}},
61-
\ ])
62-
63-
" vim:ts=4:sw=4:et
64-
```
65-
66-
Start Nvim and run the following command:
67-
68-
```vim
69-
:echo Hello('world')
70-
```
7+
Neovim/go-client is a [Neovim](https://neovim.io/) client for [Go](https://golang.org/).
718

729
Release
7310
-------

nvim/doc.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Package nvim implements a Nvim client.
22
//
3-
// See the ./plugin package for additional functionality required for writing
4-
// Nvim plugins.
5-
//
63
// The Nvim type implements the client. To connect to a running instance of
7-
// Nvim, create a *Nvim value using the Dial or NewChildProcess functions.
4+
// Nvim, create a *Nvim value using the New, Dial or NewChildProcess functions.
85
// Call the Close() method to release the resources used by the client.
96
//
107
// Use the Batch type to execute a sequence of Nvim API calls atomically. The

nvim/nvim.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ func (v *Nvim) ExitCode() int {
103103
//
104104
// The application must call Serve() to handle RPC requests and responses.
105105
//
106-
// New is a low-level function. Most applications should use NewChildProcess,
107-
// Dial or the ./plugin package.
108-
//
109106
// :help rpc-connecting
110107
func New(r io.Reader, w io.Writer, c io.Closer, logf func(string, ...interface{})) (*Nvim, error) {
111108
ep, err := rpc.NewEndpoint(r, w, c, rpc.WithLogf(logf), withExtensions())
@@ -354,8 +351,6 @@ func Dial(address string, options ...DialOption) (*Nvim, error) {
354351
// :help rpcrequest()
355352
// :help rpcnotify()
356353
//
357-
// Plugin applications should use the Handler* methods in the ./plugin package
358-
// to register handlers instead of this method.
359354
func (v *Nvim) RegisterHandler(method string, fn interface{}) error {
360355
var args []interface{}
361356
t := reflect.TypeOf(fn)

nvim/plugin/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Status
2+
------
3+
4+
This package will be deprecated when Neovim [removes the concept of
5+
remote plugins](https://github.com/neovim/neovim/issues/27949).
6+
7+
8+
Example
9+
-------
10+
11+
This example plugin adds the Hello command to Nvim.
12+
13+
```go
14+
package main
15+
16+
import (
17+
"strings"
18+
"github.com/neovim/go-client/nvim/plugin"
19+
)
20+
21+
func hello(args []string) (string, error) {
22+
return "Hello " + strings.Join(args, " "), nil
23+
}
24+
25+
func main() {
26+
plugin.Main(func(p *plugin.Plugin) error {
27+
p.HandleFunction(&plugin.FunctionOptions{Name: "Hello"}, hello)
28+
return nil
29+
})
30+
}
31+
```
32+
33+
Build the program with the [go tool](https://golang.org/cmd/go/) to an
34+
executable named `hello`. Ensure that the executable is in a directory in
35+
the `PATH` environment variable.
36+
37+
```bash
38+
// Use the `go build` command to generate an executable.
39+
// To ensure this "hello" executable is on your path,
40+
// you can move "hello" to your $GOPATH/bin directory
41+
// or add the current directory to the `PATH` environment variable.
42+
go build -o hello
43+
```
44+
45+
Add the following plugin to Nvim:
46+
47+
```vim
48+
if exists('g:loaded_hello')
49+
finish
50+
endif
51+
let g:loaded_hello = 1
52+
53+
function! s:Requirehello(host) abort
54+
" 'hello' is the binary created by compiling the program above.
55+
return jobstart(['hello'], {'rpc': v:true})
56+
endfunction
57+
58+
call remote#host#Register('hello', 'x', function('s:Requirehello'))
59+
" The following lines are generated by running the program
60+
" command line flag --manifest hello
61+
call remote#host#RegisterPlugin('hello', '0', [
62+
\ {'type': 'function', 'name': 'Hello', 'sync': 1, 'opts': {}},
63+
\ ])
64+
65+
" vim:ts=4:sw=4:et
66+
```
67+
68+
Start Nvim and run the following command:
69+
70+
```vim
71+
:echo Hello('world')
72+
```
73+
74+

0 commit comments

Comments
 (0)