Class: Neovim::Manifest
- Inherits:
-
Object
- Object
- Neovim::Manifest
- Includes:
- Logging
- Defined in:
- lib/neovim/manifest.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Instance Method Summary collapse
-
#handle(message, client) ⇒ Object
Handle messages received from the host.
-
#initialize ⇒ Manifest
constructor
A new instance of Manifest.
-
#register(plugin) ⇒ Object
Register a
Plugin
to receiveHost
messages.
Constructor Details
#initialize ⇒ Manifest
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
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
7 8 9 |
# File 'lib/neovim/manifest.rb', line 7 def handlers @handlers end |
#specs ⇒ Object (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.
31 32 33 34 35 36 37 |
# File 'lib/neovim/manifest.rb', line 31 def handle(, client) default_handler = .sync? ? default_sync_handler : default_async_handler @handlers.fetch(.method_name, default_handler).call(client, ) rescue => e fatal("got unexpected error #{e}") debug(e.backtrace.join("\n")) end |
#register(plugin) ⇒ Object
Register a Plugin
to receive Host
messages.
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 |