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 vim_get_api_info RPC call. Some methods return RemoteObject subclasses (i.e. Buffer, Window, or Tabpage), which similarly have dynamically generated interfaces.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Client



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

def initialize(session)
  session.discover_api

  @session = session
  @api = session.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.



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

def method_missing(method_name, *args)
  if func = @api.function("vim_#{method_name}")
    func.call(@session, *args)
  else
    super
  end
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



13
14
15
# File 'lib/neovim/client.rb', line 13

def session
  @session
end

Instance Method Details

#call_function(fname, args) ⇒ Object



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


#change_directory(dir) ⇒ void



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


#command(str) ⇒ void



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


#command_output(str) ⇒ String



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


#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"

See Also:



49
50
51
# File 'lib/neovim/client.rb', line 49

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

#del_current_linevoid



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


#err_write(str) ⇒ void



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


#eval(str) ⇒ Object



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


#evaluate(expr) ⇒ Object

Evaluate the VimL expression (alias for vim_eval).

Examples:

Return a list from VimL

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


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

def evaluate(expr)
  @api.function(:vim_eval).call(@session, expr)
end

#feedkeys(keys, mode, escape_csi) ⇒ void



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


#get_api_infoArray



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


#get_buffersArray<Buffer>



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


#get_color_mapDictionary



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


#get_current_bufferBuffer



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


#get_current_lineString



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


#get_current_tabpageTabpage



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


#get_current_windowWindow



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


#get_option(name) ⇒ Object



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


#get_tabpagesArray<Tabpage>



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


#get_var(name) ⇒ Object



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


#get_vvar(name) ⇒ Object



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


#get_windowsArray<Window>



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


#input(keys) ⇒ Fixnum



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


#list_runtime_pathsArray<String>



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


#message(string) ⇒ void

This method returns an undefined value.

Display a message.



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

def message(string)
  out_write(string)
end

#methodsObject

Extend methods to include RPC methods.



37
38
39
# File 'lib/neovim/client.rb', line 37

def methods
  super | rpc_methods
end

#name_to_color(name) ⇒ Fixnum



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


#out_write(str) ⇒ void



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


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



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


#report_error(str) ⇒ void



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


#respond_to?(method_name) ⇒ Boolean

Extend respond_to? to support RPC methods.



32
33
34
# File 'lib/neovim/client.rb', line 32

def respond_to?(method_name)
  super || rpc_methods.include?(method_name.to_sym)
end

#set_current_buffer(buffer) ⇒ void



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


#set_current_line(line) ⇒ void



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


#set_current_tabpage(tabpage) ⇒ void



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


#set_current_window(window) ⇒ void



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


#set_option(name, value) ⇒ void



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


#set_var(name, value) ⇒ Object



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


#strwidth(str) ⇒ Fixnum



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


#subscribe(event) ⇒ void



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


#unsubscribe(event) ⇒ void



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