class Neovim::Client
Client to a running nvim instance. The interface is generated at runtime via the nvim_get_api_info RPC call. Some methods return RemoteObject subclasses (i.e. Buffer, Window, or Tabpage), which similarly have dynamically generated interfaces.
The methods documented here were generated using NVIM v0.5.0
Attributes
Public Class Methods
# File lib/neovim/client.rb, line 20 def self.from_event_loop(event_loop, session=Session.new(event_loop)) api = API.new(session.request(:nvim_get_api_info)) event_loop.register_types(api, session) new(session, api) end
# File lib/neovim/client.rb, line 27 def initialize(session, api) @session = session @api = api end
Public Instance Methods
# File lib/neovim/client.rb, line 32 def channel_id @api.channel_id end
Access to objects belonging to the current nvim context.
@return [Current] @example Get the current buffer
client.current.buffer
@example Set the current line
client.current.line = "New line"
@see Current
# File lib/neovim/client.rb, line 63 def current @current ||= Current.new(@session) end
Evaluate the VimL expression (alias for nvim_eval).
@param expr [String] A VimL expression. @return [Object] @example Return a list from VimL
client.evaluate('[1, 2]') # => [1, 2]
# File lib/neovim/client.rb, line 73 def evaluate(expr) @api.function_for_object_method(self, :eval).call(@session, expr) end
Display a message.
@param string [String] The message. @return [void]
# File lib/neovim/client.rb, line 81 def message(string) out_write(string) end
Intercept method calls and delegate to appropriate RPC methods.
# File lib/neovim/client.rb, line 37 def method_missing(method_name, *args) if (func = @api.function_for_object_method(self, method_name)) func.call(@session, *args) else super end end
Extend methods to include RPC methods.
# File lib/neovim/client.rb, line 51 def methods(*args) super | rpc_methods.to_a end
Extend respond_to_missing? to support RPC methods.
# File lib/neovim/client.rb, line 46 def respond_to_missing?(method_name, *) super || rpc_methods.include?(method_name.to_sym) end
Set an option.
@overload set_option(key, value)
@param [String] key @param [String] value
@overload set_option(optstr)
@param [String] optstr
@example Set the timeoutlen option
client.set_option("timeoutlen", 0) client.set_option("timeoutlen=0")
# File lib/neovim/client.rb, line 97 def set_option(*args) if args.size > 1 @api.function_for_object_method(self, :set_option).call(@session, *args) else @api.function_for_object_method(self, :command).call(@session, "set #{args.first}") end end
# File lib/neovim/client.rb, line 105 def shutdown @session.shutdown end
Private Instance Methods
# File lib/neovim/client.rb, line 111 def rpc_methods @rpc_methods ||= @api.functions_for_object(self).map(&:method_name).to_set end