Class: Neovim::Manifest

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/neovim/manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included

Constructor Details

#initializeManifest

Returns a new instance of Manifest.



9
10
11
12
# File 'lib/neovim/manifest.rb', line 9

def initialize
  @handlers = {"poll" => poll_handler, "specs" => specs_handler}
  @specs = {}
end

Instance Attribute Details

#handlersObject (readonly)

Returns the value of attribute handlers.



7
8
9
# File 'lib/neovim/manifest.rb', line 7

def handlers
  @handlers
end

#specsObject (readonly)

Returns the value of attribute specs.



7
8
9
# File 'lib/neovim/manifest.rb', line 7

def specs
  @specs
end

Instance Method Details

#handle(message, client) ⇒ Object

Handle messages received from the host. Sends a Neovim::Client along with the message to be used in plugin callbacks.

Parameters:



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

def handle(message, client)
  default_handler = message.sync? ? default_sync_handler : default_async_handler
  @handlers.fetch(message.method_name, default_handler).call(client, message)
rescue => e
  fatal("got unexpected error #{e}")
  debug(e.backtrace.join("\n"))
end

#register(plugin) ⇒ Object

Register a Plugin to receive Host messages.

Parameters:



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

def register(plugin)
  plugin.handlers.each do |handler|
    wrapped_handler = handler.sync? ? wrap_sync(handler) : wrap_async(handler)
    @handlers[handler.qualified_name] = wrapped_handler
  end

  @specs[plugin.source] = plugin.specs
end