Skip to content

Intentions API : List

Steel Brain edited this page Mar 18, 2016 · 3 revisions

Intentions List API allows you to show intentions from your package based on scopes

Defining a provider

You'll need to add this in your package.json

"providedServices": {
  "intentions:list": {
    "versions": {
      "1.0.0": "provideIntentions"
    }
  }
}

and you should return a provider object from provideIntentions function of your package

Note: You can return more than one providers at once by wrapping them in an array

Note: Supported icons are octicons

module.exports = {
  activate: function() {
    console.log('activate')
  },
  provideIntentions: function() {
    // Structure of an provider object
    return {
      grammarScopes: ['source.js'],    // ['*'] also works
      getIntentions: function({textEditor, bufferPosition}) {
        // Highest priority is shown first of all
        // Note: You can also return a Promise
        return [
          {
            priority: 100,
            icon: 'bucket',
            class: 'custom-icon-class',
            title: 'Choose color from colorpicker',
            selected: function() {
              console.log('You clicked the color picker option')
            }
          },
          {
            priority: 200,
            icon: 'tools',
            title: 'Fix linter issue',
            selected: function() {
              console.log('You chose to fix linter issue')
            }
          }
        ]
      }
    }
  }
}

The above provider produces these items in intentions list Screenshot

Clone this wiki locally