How to create a minimap plugin?

A Minimap plugin is just another Atom package that interacts with the Minimap API. To get started, use the Minimap: Generate Plugin command in Atom. This will bootstrap a new minimap plugin with the basic interface and behavior expected from plugins.

Minimap Plugin Interface

In addition of the Atom package interface, a Minimap plugin implements the following methods:

These methods allow plugins to be activated/deactivated by the Minimap package independently of their activation as a package.

Minimap Settings

All Minimap plugins are activated by default.

A Minimal Minimap Plugin

{CompositeDisposable} = require 'event-kit'

module.exports =
  active: false

  isActive: -> @active

  activate: (state) ->
    # During the activation, the minimap package is retrieved.
    atom.packages.activatePackage('minimap').then (pkg) =>
      @minimap = pkg.mainModule

      # And a test against the minimap version allow to prevent compatibility
      # issues.
      return @deactivate() unless @minimap.versionMatch('4.x')

      # The subscriptions object will store the disposable returned when
      # registering to minimap events.
      @subscriptions = new CompositeDisposable

      # The plugin is then registered as a plugin in the minimap.
      @minimap.registerPlugin 'plugin-name', this

  deactivate: ->
    @minimap.unregisterPlugin 'plugin-name'
    @minimap = null

  activatePlugin: ->
    return if @active

    @active = true

    @subscriptions.add @minimap.onDidActivate =>
      # do something when the minimap is activated

    @subscriptions.add @minimap.onDidDeactivate =>
      # do something when the minimap is deactivated

    @subscriptions.add @minimap.observeMinimaps (minimap) ->
      # do something each time a minimap is created.

  deactivatePlugin: ->
    return unless @active

    @active = false
    @subscriptions.dispose()

Minimap Plugin API

The Minimap package provides a simple API for plugins: