Sha256: fd9f8a0bde85c7236804e79d7f10490f6e8fb2e1098eb730d129e67b3ea60c26

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module Neovim
  class Plugin
    # @api private
    class Handler
      attr_reader :block

      def self.unqualified(name, block)
        new(nil, nil, name, true, {qualified: false}, block)
      end

      def initialize(source, type, name, sync, options, block)
        @source = source
        @type = type.to_sym if type.respond_to?(:to_sym)
        @name = name.to_s
        @sync = sync
        @options = options
        @block = block || -> {}
        @qualified =
          options.key?(:qualified) ? options.delete(:qualified) : true
      end

      def sync?
        !!@sync
      end

      def qualified?
        @qualified
      end

      def qualified_name
        return @name unless qualified?

        if @type == :autocmd
          pattern = @options.fetch(:pattern, "*")
          "#{@source}:#{@type}:#{@name}:#{pattern}"
        else
          "#{@source}:#{@type}:#{@name}"
        end
      end

      def to_spec
        {
          type: @type,
          name: @name,
          sync: @sync,
          opts: @options
        }
      end

      def call(*args)
        @block.call(*args)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
neovim-0.10.0 lib/neovim/plugin/handler.rb
neovim-0.9.1 lib/neovim/plugin/handler.rb
neovim-0.9.0 lib/neovim/plugin/handler.rb
neovim-0.9.0.pre.1 lib/neovim/plugin/handler.rb
neovim-0.8.1 lib/neovim/plugin/handler.rb
neovim-0.8.0 lib/neovim/plugin/handler.rb
neovim-0.7.1 lib/neovim/plugin/handler.rb