Sha256: 51665215b9b843c9f9b87e86a5d6778501a29e1df9db4103ebfb0d32f161eeb5

Contents?: true

Size: 727 Bytes

Versions: 8

Compression:

Stored size: 727 Bytes

Contents

require "neovim/plugin"

module Neovim
  class Host
    # @api private
    class Loader
      def initialize(host)
        @host = host
      end

      def load(paths)
        paths.each do |path|
          override_plugin_method(path) do
            Kernel.load(path, true)
          end
        end
      end

      private

      def override_plugin_method(path)
        old_plugin_def = Neovim.method(:plugin)
        at_host = @host

        Neovim.define_singleton_method(:plugin) do |&block|
          plugin = Plugin.from_config_block(path, &block)
          at_host.plugins << plugin
        end

        yield
      ensure
        Neovim.define_singleton_method(:plugin, &old_plugin_def)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
neovim-0.10.0 lib/neovim/host/loader.rb
neovim-0.9.1 lib/neovim/host/loader.rb
neovim-0.9.0 lib/neovim/host/loader.rb
neovim-0.9.0.pre.1 lib/neovim/host/loader.rb
neovim-0.8.1 lib/neovim/host/loader.rb
neovim-0.8.0 lib/neovim/host/loader.rb
neovim-0.7.1 lib/neovim/host/loader.rb
neovim-0.7.0 lib/neovim/host/loader.rb