Skip to content

Commit

Permalink
Add a decoration order setting for each registered plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Mar 6, 2016
1 parent 2d473f1 commit b912132
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/mixins/plugin-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,39 @@ export default class PluginManagement extends Mixin {
* @access private
*/
registerPluginControls (name, plugin) {
let settingsKey = `minimap.plugins.${name}`
const settingsKey = `minimap.plugins.${name}`
const orderSettingsKey = `minimap.plugins.${name}DecorationsOrder`

this.config.plugins.properties[name] = {
type: 'boolean',
title: name,
description: `Whether the ${name} plugin is activated and displayed in the Minimap.`,
default: true
}

this.config.plugins.properties[`${name}DecorationsOrder`] = {
type: 'integer',
title: `${name} decorations order`,
description: `The relative order of the ${name} plugin's decorations in the layer into which they are drawn. Note that this order only apply inside a layer, so highlight-over decorations will always be displayed above line decorations as they are rendered in different layers.`,
default: 0
}

if (atom.config.get(settingsKey) === undefined) {
atom.config.set(settingsKey, true)
}

if (atom.config.get(orderSettingsKey) === undefined) {
atom.config.set(orderSettingsKey, 0)
}

this.pluginsSubscriptions[name].add(atom.config.observe(settingsKey, () => {
this.updatesPluginActivationState(name)
}))

this.pluginsSubscriptions[name].add(atom.config.observe(orderSettingsKey, () => {

}))

this.pluginsSubscriptions[name].add(atom.commands.add('atom-workspace', {
[`minimap:toggle-${name}`]: () => {
this.togglePluginActivation(name)
Expand Down
2 changes: 2 additions & 0 deletions spec/minimap-main-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ describe('Minimap package', () => {

it('creates a default config for the plugin', () => {
expect(minimapPackage.config.plugins.properties.dummy).toBeDefined()
expect(minimapPackage.config.plugins.properties.dummyDecorationsOrder).toBeDefined()
})

it('sets the corresponding config', () => {
expect(atom.config.get('minimap.plugins.dummy')).toBeTruthy()
expect(atom.config.get('minimap.plugins.dummyDecorationsOrder')).toEqual(0)
})

describe('triggering the corresponding plugin command', () => {
Expand Down

0 comments on commit b912132

Please sign in to comment.