Class: Neovim::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/neovim/client.rb

Overview

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.3.0

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, api) ⇒ Client

Returns a new instance of Client


26
27
28
29
# File 'lib/neovim/client.rb', line 26

def initialize(session, api)
  @session = session
  @api = api
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object

Intercept method calls and delegate to appropriate RPC methods.


32
33
34
35
36
37
38
# File 'lib/neovim/client.rb', line 32

def method_missing(method_name, *args)
  if (func = @api.function_for_object_method(self, method_name))
    func.call(@session, *args)
  else
    super
  end
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api


17
18
19
# File 'lib/neovim/client.rb', line 17

def api
  @api
end

#sessionObject (readonly)

Returns the value of attribute session


17
18
19
# File 'lib/neovim/client.rb', line 17

def session
  @session
end

Class Method Details

.from_event_loop(event_loop, session = Session.new(event_loop)) ⇒ Object


19
20
21
22
23
24
# File 'lib/neovim/client.rb', line 19

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

Instance Method Details

#call_atomic(calls) ⇒ Array

See :h nvim_call_atomic()

Parameters:

  • calls (Array)

Returns:

  • (Array)

# File 'lib/neovim/client.rb', line 114

#call_dict_function(dict, fn, args) ⇒ Object

See :h nvim_call_dict_function()

Parameters:

  • dict (Object)
  • fn (String)
  • args (Array)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#call_function(fn, args) ⇒ Object

See :h nvim_call_function()

Parameters:

  • fn (String)
  • args (Array)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#command(command) ⇒ void

This method returns an undefined value.

See :h nvim_command()

Parameters:

  • command (String)

# File 'lib/neovim/client.rb', line 114

#command_output(command) ⇒ String

See :h nvim_command_output()

Parameters:

  • command (String)

Returns:

  • (String)

# File 'lib/neovim/client.rb', line 114

#currentCurrent

Access to objects belonging to the current nvim context.

Examples:

Get the current buffer

client.current.buffer

Set the current line

client.current.line = "New line"

Returns:

See Also:


58
59
60
# File 'lib/neovim/client.rb', line 58

def current
  @current ||= Current.new(@session)
end

#del_current_linevoid

This method returns an undefined value.

See :h nvim_del_current_line()


# File 'lib/neovim/client.rb', line 114

#del_var(name) ⇒ void

This method returns an undefined value.

See :h nvim_del_var()

Parameters:

  • name (String)

# File 'lib/neovim/client.rb', line 114

#err_write(str) ⇒ void

This method returns an undefined value.

See :h nvim_err_write()

Parameters:

  • str (String)

# File 'lib/neovim/client.rb', line 114

#err_writeln(str) ⇒ void

This method returns an undefined value.

See :h nvim_err_writeln()

Parameters:

  • str (String)

# File 'lib/neovim/client.rb', line 114

#eval(expr) ⇒ Object

See :h nvim_eval()

Parameters:

  • expr (String)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#evaluate(expr) ⇒ Object

Evaluate the VimL expression (alias for nvim_eval).

Examples:

Return a list from VimL

client.evaluate('[1, 2]') # => [1, 2]

Parameters:

  • expr (String)

    A VimL expression.

Returns:

  • (Object)

68
69
70
# File 'lib/neovim/client.rb', line 68

def evaluate(expr)
  @api.function_for_object_method(self, :eval).call(@session, expr)
end

#execute_lua(code, args) ⇒ Object

See :h nvim_execute_lua()

Parameters:

  • code (String)
  • args (Array)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#feedkeys(keys, mode, escape_csi) ⇒ void

This method returns an undefined value.

See :h nvim_feedkeys()

Parameters:

  • keys (String)
  • mode (String)
  • escape_csi (Boolean)

# File 'lib/neovim/client.rb', line 114

#get_api_infoArray

See :h nvim_get_api_info()

Returns:

  • (Array)

# File 'lib/neovim/client.rb', line 114

#get_chan_info(chan) ⇒ Hash

See :h nvim_get_chan_info()

Parameters:

  • chan (Integer)

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#get_color_by_name(name) ⇒ Integer

See :h nvim_get_color_by_name()

Parameters:

  • name (String)

Returns:

  • (Integer)

# File 'lib/neovim/client.rb', line 114

#get_color_mapHash

See :h nvim_get_color_map()

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#get_commands(opts) ⇒ Hash

See :h nvim_get_commands()

Parameters:

  • opts (Hash)

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#get_current_bufBuffer

See :h nvim_get_current_buf()

Returns:


# File 'lib/neovim/client.rb', line 114

#get_current_lineString

See :h nvim_get_current_line()

Returns:

  • (String)

# File 'lib/neovim/client.rb', line 114

#get_current_tabpageTabpage

See :h nvim_get_current_tabpage()

Returns:


# File 'lib/neovim/client.rb', line 114

#get_current_winWindow

See :h nvim_get_current_win()

Returns:


# File 'lib/neovim/client.rb', line 114

#get_hl_by_id(hl_id, rgb) ⇒ Hash

See :h nvim_get_hl_by_id()

Parameters:

  • hl_id (Integer)
  • rgb (Boolean)

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#get_hl_by_name(name, rgb) ⇒ Hash

See :h nvim_get_hl_by_name()

Parameters:

  • name (String)
  • rgb (Boolean)

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#get_keymap(mode) ⇒ Array<Hash>

See :h nvim_get_keymap()

Parameters:

  • mode (String)

Returns:

  • (Array<Hash>)

# File 'lib/neovim/client.rb', line 114

#get_modeHash

See :h nvim_get_mode()

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#get_option(name) ⇒ Object

See :h nvim_get_option()

Parameters:

  • name (String)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#get_proc(pid) ⇒ Object

See :h nvim_get_proc()

Parameters:

  • pid (Integer)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#get_proc_children(pid) ⇒ Array

See :h nvim_get_proc_children()

Parameters:

  • pid (Integer)

Returns:

  • (Array)

# File 'lib/neovim/client.rb', line 114

#get_var(name) ⇒ Object

See :h nvim_get_var()

Parameters:

  • name (String)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#get_vvar(name) ⇒ Object

See :h nvim_get_vvar()

Parameters:

  • name (String)

Returns:

  • (Object)

# File 'lib/neovim/client.rb', line 114

#input(keys) ⇒ Integer

See :h nvim_input()

Parameters:

  • keys (String)

Returns:

  • (Integer)

# File 'lib/neovim/client.rb', line 114

#list_bufsArray<Buffer>

See :h nvim_list_bufs()

Returns:


# File 'lib/neovim/client.rb', line 114

#list_chansArray

See :h nvim_list_chans()

Returns:

  • (Array)

# File 'lib/neovim/client.rb', line 114

#list_runtime_pathsArray<String>

See :h nvim_list_runtime_paths()

Returns:

  • (Array<String>)

# File 'lib/neovim/client.rb', line 114

#list_tabpagesArray<Tabpage>

See :h nvim_list_tabpages()

Returns:


# File 'lib/neovim/client.rb', line 114

#list_uisArray

See :h nvim_list_uis()

Returns:

  • (Array)

# File 'lib/neovim/client.rb', line 114

#list_winsArray<Window>

See :h nvim_list_wins()

Returns:


# File 'lib/neovim/client.rb', line 114

#message(string) ⇒ void

This method returns an undefined value.

Display a message.

Parameters:

  • string (String)

    The message.


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

def message(string)
  out_write(string)
end

#methods(*args) ⇒ Object

Extend methods to include RPC methods.


46
47
48
# File 'lib/neovim/client.rb', line 46

def methods(*args)
  super | rpc_methods
end

#out_write(str) ⇒ void

This method returns an undefined value.

See :h nvim_out_write()

Parameters:

  • str (String)

# File 'lib/neovim/client.rb', line 114

#parse_expression(expr, flags, highlight) ⇒ Hash

See :h nvim_parse_expression()

Parameters:

  • expr (String)
  • flags (String)
  • highlight (Boolean)

Returns:

  • (Hash)

# File 'lib/neovim/client.rb', line 114

#replace_termcodes(str, from_part, do_lt, special) ⇒ String

See :h nvim_replace_termcodes()

Parameters:

  • str (String)
  • from_part (Boolean)
  • do_lt (Boolean)
  • special (Boolean)

Returns:

  • (String)

# File 'lib/neovim/client.rb', line 114

#respond_to_missing?(method_name) ⇒ Boolean

Extend respond_to_missing? to support RPC methods.

Returns:

  • (Boolean)

41
42
43
# File 'lib/neovim/client.rb', line 41

def respond_to_missing?(method_name, *)
  super || rpc_methods.include?(method_name.to_sym)
end

#set_client_info(name, version, type, methods, attributes) ⇒ void

This method returns an undefined value.

See :h nvim_set_client_info()

Parameters:

  • name (String)
  • version (Hash)
  • type (String)
  • methods (Hash)
  • attributes (Hash)

# File 'lib/neovim/client.rb', line 114

#set_current_buf(buffer) ⇒ void

This method returns an undefined value.

See :h nvim_set_current_buf()

Parameters:


# File 'lib/neovim/client.rb', line 114

#set_current_dir(dir) ⇒ void

This method returns an undefined value.

See :h nvim_set_current_dir()

Parameters:

  • dir (String)

# File 'lib/neovim/client.rb', line 114

#set_current_line(line) ⇒ void

This method returns an undefined value.

See :h nvim_set_current_line()

Parameters:

  • line (String)

# File 'lib/neovim/client.rb', line 114

#set_current_tabpage(tabpage) ⇒ void

This method returns an undefined value.

See :h nvim_set_current_tabpage()

Parameters:


# File 'lib/neovim/client.rb', line 114

#set_current_win(window) ⇒ void

This method returns an undefined value.

See :h nvim_set_current_win()

Parameters:


# File 'lib/neovim/client.rb', line 114

#set_option(key, value) ⇒ Object #set_option(optstr) ⇒ Object

Set an option.

Examples:

Set the timeoutlen option

client.set_option("timeoutlen", 0)
client.set_option("timeoutlen=0")

Overloads:

  • #set_option(key, value) ⇒ Object

    Parameters:

    • key (String)
    • value (String)
  • #set_option(optstr) ⇒ Object

    Parameters:

    • optstr (String)

92
93
94
95
96
97
98
# File 'lib/neovim/client.rb', line 92

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

#set_var(name, value) ⇒ void

This method returns an undefined value.

See :h nvim_set_var()

Parameters:

  • name (String)
  • value (Object)

# File 'lib/neovim/client.rb', line 114

#shutdownObject


100
101
102
# File 'lib/neovim/client.rb', line 100

def shutdown
  @session.shutdown
end

#strwidth(text) ⇒ Integer

See :h nvim_strwidth()

Parameters:

  • text (String)

Returns:

  • (Integer)

# File 'lib/neovim/client.rb', line 114

#subscribe(event) ⇒ void

This method returns an undefined value.

See :h nvim_subscribe()

Parameters:

  • event (String)

# File 'lib/neovim/client.rb', line 114

#ui_attach(width, height, options) ⇒ void

This method returns an undefined value.

See :h nvim_ui_attach()

Parameters:

  • width (Integer)
  • height (Integer)
  • options (Hash)

# File 'lib/neovim/client.rb', line 114

#ui_detachvoid

This method returns an undefined value.

See :h nvim_ui_detach()


# File 'lib/neovim/client.rb', line 114

#ui_set_option(name, value) ⇒ void

This method returns an undefined value.

See :h nvim_ui_set_option()

Parameters:

  • name (String)
  • value (Object)

# File 'lib/neovim/client.rb', line 114

#ui_try_resize(width, height) ⇒ void

This method returns an undefined value.

See :h nvim_ui_try_resize()

Parameters:

  • width (Integer)
  • height (Integer)

# File 'lib/neovim/client.rb', line 114

#unsubscribe(event) ⇒ void

This method returns an undefined value.

See :h nvim_unsubscribe()

Parameters:

  • event (String)

# File 'lib/neovim/client.rb', line 114