Skip to content

Commit 32c9c99

Browse files
committed
fixup! Add basic remote module support
update README
1 parent 93c8b33 commit 32c9c99

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

README.md

+7-27
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,17 @@ client = Neovim.attach_unix("/tmp/nvim.sock")
4242

4343
Refer to the [`Neovim` docs](https://www.rubydoc.info/github/neovim/neovim-ruby/main/Neovim) for other ways to connect to `nvim`, and the [`Neovim::Client` docs](https://www.rubydoc.info/github/neovim/neovim-ruby/main/Neovim/Client) for a summary of the client interface.
4444

45-
### Plugins
45+
### Remote Modules
4646

47-
Plugins are Ruby files loaded from the `$VIMRUNTIME/rplugin/ruby/` directory. Here's an example plugin:
47+
Remote modules allow users to define custom handlers in Ruby. To implement a remote module:
4848

49-
```ruby
50-
# ~/.config/nvim/rplugin/ruby/example_plugin.rb
51-
52-
Neovim.plugin do |plug|
53-
# Define a command called "SetLine" which sets the contents of the current
54-
# line. This command is executed asynchronously, so the return value is
55-
# ignored.
56-
plug.command(:SetLine, nargs: 1) do |nvim, str|
57-
nvim.current.line = str
58-
end
59-
60-
# Define a function called "Sum" which adds two numbers. This function is
61-
# executed synchronously, so the result of the block will be returned to nvim.
62-
plug.function(:Sum, nargs: 2, sync: true) do |nvim, x, y|
63-
x + y
64-
end
65-
66-
# Define an autocmd for the BufEnter event on Ruby files.
67-
plug.autocmd(:BufEnter, pattern: "*.rb") do |nvim|
68-
nvim.command("echom 'Ruby file, eh?'")
69-
end
70-
end
71-
```
49+
- Define your handlers in a plain Ruby script that imports `neovim`
50+
- Spawn the script from lua using `jobstart`
51+
- Define commands in lua using `nvim_create_user_command` that route to the job's channel ID
7252

73-
When you add or update a plugin, you will need to call `:UpdateRemotePlugins` to update the remote plugin manifest. See `:help remote-plugin-manifest` for more information.
53+
For details, see [`example_remote_module.lua`](spec/acceptance/runtime/plugin/example_remote_module.lua) and [`remote_module_spec.vim`](spec/acceptance/remote_module_spec.vim).
7454

75-
Refer to the [`Neovim::Plugin::DSL` docs](https://www.rubydoc.info/github/neovim/neovim-ruby/main/Neovim/Plugin/DSL) for a more complete overview of the `Neovim.plugin` DSL.
55+
*Note*: Remote modules are a replacement for the deprecated "remote plugin" architecture. See https://github.com/neovim/neovim/issues/27949 for details.
7656

7757
### Vim Plugin Support
7858

spec/acceptance/runtime/plugin/example_remote_module.lua

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ local function ensure_job()
99
'ruby',
1010
'-I', 'lib',
1111
'spec/acceptance/runtime/example_remote_module.rb',
12-
}, {
13-
rpc = true,
14-
on_stderr = function(j, d, e)
15-
io.stderr:write("error: " .. table.concat(d, '\n') .. "\n")
16-
end
17-
})
12+
}, { rpc = true })
1813

1914
return chan
2015
end

0 commit comments

Comments
 (0)