Class: Neovim::Host Private

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

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: CLI, 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.

[View source] [View on GitHub]

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

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.

[View on GitHub]

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

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.

[View source] [View on GitHub]

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

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.

[View source] [View on GitHub]

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

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.

[View source] [View on GitHub]

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

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