Module: Neovim

Defined in:
lib/neovim.rb,
lib/neovim/api.rb,
lib/neovim/host.rb,
lib/neovim/buffer.rb,
lib/neovim/client.rb,
lib/neovim/plugin.rb,
lib/neovim/window.rb,
lib/neovim/current.rb,
lib/neovim/logging.rb,
lib/neovim/request.rb,
lib/neovim/session.rb,
lib/neovim/tabpage.rb,
lib/neovim/version.rb,
lib/neovim/manifest.rb,
lib/neovim/event_loop.rb,
lib/neovim/line_range.rb,
lib/neovim/plugin/dsl.rb,
lib/neovim/notification.rb,
lib/neovim/async_session.rb,
lib/neovim/remote_object.rb,
lib/neovim/msgpack_stream.rb,
lib/neovim/plugin/handler.rb

Overview

The main entrypoint to the Neovim gem. It allows you to connect to a running nvim instance programmatically or define a remote plugin to be autoloaded by nvim.

You can connect to a running nvim instance by setting or inspecting the NVIM_LISTEN_ADDRESS environment variable and connecting via the appropriate attach_ method. This is currently supported for both UNIX domain sockets and TCP. You can also spawn and connect to an nvim subprocess via Neovim.attach_child(argv).

You can define a remote plugin using the Neovim.plugin DSL, which allows you to register commands, functions, and autocmds. Plugins are autoloaded by nvim from the rplugin/ruby directory in your nvim runtime path.

Examples:

Connect over a TCP socket

Neovim.attach_tcp("0.0.0.0", 3333) # => Neovim::Client

Connect over a UNIX domain socket

Neovim.attach_unix("/tmp/nvim.sock") # => Neovim::Client

Spawn and connect to a child nvim process

Neovim.attach_child(["-u", "NONE"]) # => Neovim::Client

Define a Ruby plugin

# ~/.config/nvim/rplugin/ruby/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

See Also:

Defined Under Namespace

Modules: Logging Classes: API, AsyncSession, Buffer, Client, Current, EventLoop, Host, LineRange, Manifest, MsgpackStream, Notification, Plugin, RemoteObject, Request, Session, Tabpage, Window

Constant Summary collapse

VERSION =
Gem::Version.new("0.0.6")

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.__configured_plugin_manifestManifest?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



62
63
64
# File 'lib/neovim.rb', line 62

def __configured_plugin_manifest
  @__configured_plugin_manifest
end

.__configured_plugin_pathString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String, nil)


66
67
68
# File 'lib/neovim.rb', line 66

def __configured_plugin_path
  @__configured_plugin_path
end

Class Method Details

.attach_child(argv = []) ⇒ Client

Spawn and connect to a child nvim process.

Parameters:

  • argv (Array) (defaults to: [])

    The arguments to pass to the spawned process

Returns:

See Also:



93
94
95
# File 'lib/neovim.rb', line 93

def self.attach_child(argv=[])
  Client.new(Session.child(argv).discover_api)
end

.attach_tcp(host, port) ⇒ Client

Connect to a running nvim instance over TCP.

Parameters:

  • host (String)

    The hostname or IP address

  • port (Fixnum)

    The port

Returns:

See Also:



75
76
77
# File 'lib/neovim.rb', line 75

def self.attach_tcp(host, port)
  Client.new(Session.tcp(host, port).discover_api)
end

.attach_unix(socket_path) ⇒ Client

Connect to a running nvim instance over a UNIX domain socket.

Parameters:

  • socket_path (String)

    The socket path

Returns:

See Also:



84
85
86
# File 'lib/neovim.rb', line 84

def self.attach_unix(socket_path)
  Client.new(Session.unix(socket_path).discover_api)
end

.loggerLogger

The Neovim global logger.

Returns:

  • (Logger)

See Also:



134
135
136
# File 'lib/neovim.rb', line 134

def self.logger
  Logging.logger
end

.logger=(logger) ⇒ Logger

Set the Neovim global logger.

Parameters:

  • logger (Logger)

    The target logger

Returns:

  • (Logger)

See Also:



126
127
128
# File 'lib/neovim.rb', line 126

def self.logger=(logger)
  Logging.logger = logger
end

.plugin {|Plugin::DSL| ... } ⇒ Plugin

Define an nvim remote plugin using the plugin DSL.

Yields:

Returns:

See Also:



102
103
104
105
106
107
108
# File 'lib/neovim.rb', line 102

def self.plugin(&block)
  Plugin.from_config_block(__configured_plugin_path, &block).tap do |plugin|
    if __configured_plugin_manifest.respond_to?(:register)
      __configured_plugin_manifest.register(plugin)
    end
  end
end

.start_host(rplugin_paths) ⇒ void

This method returns an undefined value.

Start a plugin host. This is called by the nvim-ruby-host executable, which is spawned by nvim to discover and run Ruby plugins, and acts as the bridge between nvim and the plugin.

Parameters:

  • rplugin_paths (Array<String>)

    The paths to remote plugin files

See Also:



117
118
119
# File 'lib/neovim.rb', line 117

def self.start_host(rplugin_paths)
  Host.load_from_files(rplugin_paths).run
end

Instance Method Details

#get_var(name) ⇒ Object

Parameters:

  • name (String)

Returns:

  • (Object)


# File 'lib/neovim/tabpage.rb', line 8

#get_windowWindow

Returns:



# File 'lib/neovim/tabpage.rb', line 8

#get_windowsArray<Window>

Returns:



# File 'lib/neovim/tabpage.rb', line 8

#is_validBoolean

Returns:

  • (Boolean)


# File 'lib/neovim/tabpage.rb', line 8

#set_var(name, value) ⇒ Object

Parameters:

  • name (String)
  • value (Object)

Returns:

  • (Object)


# File 'lib/neovim/tabpage.rb', line 8