Class: Neovim::Host

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included

Constructor Details

#initialize(manifest, session = nil) ⇒ Host

Returns a new instance of Host.



43
44
45
46
# File 'lib/neovim/host.rb', line 43

def initialize(manifest, session=nil)
  @session = session || Session.stdio
  @manifest = manifest
end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



8
9
10
# File 'lib/neovim/host.rb', line 8

def manifest
  @manifest
end

Class Method Details

.load_from_files(rplugin_paths) ⇒ Host .load_from_files(rplugin_paths, target_manifest) ⇒ Host

Load plugin definitions and instantiate a new Host. This temporarily mutates global state on the Neovim module so that Neovim.plugin calls will be registered correctly with the provided Manifest.

Overloads:

  • .load_from_files(rplugin_paths) ⇒ Host

    Parameters:

    • rplugin_paths (Array<String>)

      The remote plugin paths.

  • .load_from_files(rplugin_paths, target_manifest) ⇒ Host

    Parameters:

    • rplugin_paths (Array<String>)

      The remote plugin paths.

    • target_manifest (Manifest)

      The plugin manifest.

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/neovim/host.rb', line 24

def self.load_from_files(rplugin_paths, target_manifest=Manifest.new)
  old_manifest = Neovim.__configured_plugin_manifest
  old_path = Neovim.__configured_plugin_path

  begin
    Neovim.__configured_plugin_manifest = target_manifest

    rplugin_paths.each do |rplugin_path|
      Neovim.__configured_plugin_path = rplugin_path
      Kernel.load(rplugin_path, true)
    end

    new(target_manifest)
  ensure
    Neovim.__configured_plugin_manifest = old_manifest
    Neovim.__configured_plugin_path = old_path
  end
end

Instance Method Details

#runvoid

This method returns an undefined value.

Run the event loop, passing received messages to the manifest.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/neovim/host.rb', line 51

def run
  @session.discover_api

  @session.run do |msg|
    debug("received #{msg.inspect}")
    @manifest.handle(msg, client)
  end
rescue => e
  fatal("got unexpected error #{e}")
  debug(e.backtrace.join("\n"))
end