Class: Neovim::Host Private

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/neovim/host.rb,
lib/neovim/host/loader.rb

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

Defined Under Namespace

Classes: Loader

Constant Summary

Constants included from Logging

Logging::TIMESTAMP_FORMAT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, logger, logger=

Constructor Details

#initialize(event_loop) ⇒ Host

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 a new instance of Host


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

def initialize(event_loop)
  @event_loop = event_loop
  @session = Session.new(event_loop)
  @handlers = {"poll" => poll_handler, "specs" => specs_handler}
  @plugins = []
  @specs = {}
end

Instance Attribute Details

#pluginsObject (readonly)

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.


11
12
13
# File 'lib/neovim/host.rb', line 11

def plugins
  @plugins
end

Class Method Details

.run(rplugin_paths, event_loop = EventLoop.stdio) ⇒ Object

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.


13
14
15
16
17
# File 'lib/neovim/host.rb', line 13

def self.run(rplugin_paths, event_loop=EventLoop.stdio)
  new(event_loop).tap do |host|
    Loader.new(host).load(rplugin_paths)
  end.run
end

Instance Method Details

#handle(message) ⇒ Object

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.


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/neovim/host.rb', line 31

def handle(message)
  log(:debug) { message.to_h }

  @handlers
    .fetch(message.method_name, default_handler)
    .call(@client, message)
rescue Exception => e
  log_exception(:error, e, __method__)

  if message.sync?
    @session.respond(message.id, nil, e.message)
  else
    @client.err_writeln("Exception handling #{message.method_name}: (#{e.class}) #{e.message}")
  end

  raise unless e.is_a?(StandardError)
end

#runObject

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.


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

def run
  @session.run { |msg| handle(msg) }
end