Skip to content
Ruby support for Neovim
Ruby Vim script Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
exe Set gem bindir to `exe/` Jun 9, 2018
lib Update generated docs Jul 8, 2019
script Revert to extensions on scripts. Required because appveyor cant rely … Jul 10, 2019
spec Set client info on ruby provider startup (#61) Jun 3, 2019
.gitignore ignore .vim-flavor May 30, 2019
.rubocop.yml Set client info on ruby provider startup (#61) Jun 3, 2019
.travis.yml remove extra nvim download Jul 10, 2019
CHANGELOG.md Bump to 0.8.1 and update changelog Jun 21, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Jul 18, 2017
Gemfile Use new vim-flavor release, keep flavors up to date Jan 31, 2018
LICENSE.txt initial commit May 13, 2014
README.md Fix appveyor badge URL May 31, 2019
Rakefile Revert to extensions on scripts. Required because appveyor cant rely … Jul 10, 2019
VimFlavor Use new vim-flavor release, keep flavors up to date Jan 31, 2018
appveyor.yml Narrow scope of appveyor build to bypass weird release issues May 31, 2019
neovim.gemspec

README.md

Neovim Ruby

Travis Build status Gem Version Inline docs

Ruby bindings for Neovim.

Warning: This project follows Semantic Versioning, thus its API should be considered unstable until it reaches v1.0.0 (spec).

Installation

Add this line to your application's Gemfile:

gem "neovim"

And then execute:

$ bundle

Or install it yourself as:

$ gem install neovim

Usage

You can control a running nvim process by connecting to $NVIM_LISTEN_ADDRESS. For example, to connect to nvim over a UNIX domain socket, start it up like this:

$ NVIM_LISTEN_ADDRESS=/tmp/nvim.sock nvim

You can then connect to that socket path to get a Neovim::Client:

require "neovim"
client = Neovim.attach_unix("/tmp/nvim.sock")

Refer to the Neovim docs for other ways to connect to nvim, and the Neovim::Client docs for a summary of the client interface.

Plugins

Plugins are Ruby files loaded from the $VIMRUNTIME/rplugin/ruby/ directory. Here's an example plugin:

# ~/.config/nvim/rplugin/ruby/example_plugin.rb

Neovim.plugin do |plug|
  # Define a command called "SetLine" which sets the contents of the current
  # line. This command is executed asynchronously, so the return value is
  # ignored.
  plug.command(:SetLine, nargs: 1) do |nvim, str|
    nvim.current.line = str
  end

  # Define a function called "Sum" which adds two numbers. This function is
  # executed synchronously, so the result of the block will be returned to nvim.
  plug.function(:Sum, nargs: 2, sync: true) do |nvim, x, y|
    x + y
  end

  # Define an autocmd for the BufEnter event on Ruby files.
  plug.autocmd(:BufEnter, pattern: "*.rb") do |nvim|
    nvim.command("echom 'Ruby file, eh?'")
  end
end

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.

Refer to the Neovim::Plugin::DSL docs for a more complete overview of the Neovim.plugin DSL.

Vim Plugin Support

The Neovim gem also acts as a compatibility layer for Ruby plugins written for vim. The :ruby, :rubyfile, and :rubydo commands are intended to match their original behavior, and their documentation can be found here.

Links

Contributing

  1. Fork it (http://github.com/neovim/neovim-ruby/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
You can’t perform that action at this time.