├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── ci └── build-package.sh ├── lib ├── minimap-pigments-binding.coffee └── minimap-pigments.coffee ├── package.json ├── screenshot.png ├── spec ├── fixtures │ └── sample.sass └── minimap-pigments-spec.coffee └── styles └── minimap-pigments.less /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | notifications: 4 | email: 5 | on_success: never 6 | on_failure: change 7 | 8 | env: 9 | - APM_TEST_PACKAGES="pigments" 10 | 11 | script: 'curl -s https://raw.githubusercontent.com/abe33/minimap-pigments/master/ci/build-package.sh | sh' 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # v0.2.2 (2016-12-02) 3 | 4 | ## :bug: Bug Fixes 5 | 6 | - Fix initialize now being a reserved package method ([f78ed887](https://github.com/abe33/minimap-pigments/commit/f78ed88763d3c4ff13cdad872d5f93709bf58428)) 7 | 8 | 9 | # v0.2.1 (2016-05-07) 10 | 11 | ## :bug: Bug Fixes 12 | 13 | - Fix deprecations with master Atom ([6544cb37](https://github.com/abe33/minimap-pigments/commit/6544cb37aff43eb6232b36d791e10b3a90e9e48e)) 14 | 15 | 16 | # v0.2.0 (2016-03-07) 17 | 18 | ## :sparkles: Features 19 | 20 | - Add plugin origin on created markers ([2994c3dc](https://github.com/abe33/minimap-pigments/commit/2994c3dc28601b438dbf3e2ee5e40e9b6fb0f8eb)) 21 | 22 | 23 | # v0.1.7 (2015-10-05) 24 | 25 | ## :bug: Bug Fixes 26 | 27 | - Prevent errors raised when destroying decorations ([8ce5b2bf](https://github.com/abe33/minimap-pigments/commit/8ce5b2bf74b676f9481cb01e07130121752329ee), [#2](https://github.com/abe33/minimap-pigments/issues/2)) 28 | 29 | 30 | # v0.1.6 (2015-08-20) 31 | 32 | ## :bug: Bug Fixes 33 | 34 | - Fix error raised if the subscription for a binding was already disposed ([59978722](https://github.com/abe33/minimap-pigments/commit/59978722e365e80fcff5b13c589d7433b97dfbad), [#1](https://github.com/abe33/minimap-pigments/issues/1)) 35 | 36 | 37 | # v0.1.5 (2015-08-18) 38 | 39 | ## :memo: Documentation 40 | 41 | Add missing keywords and description in `package.json` 42 | 43 | 44 | # v0.1.4 (2015-08-18) 45 | 46 | ## :bug: Bug Fixes 47 | 48 | - Fix decorations not destroyed when plugin is deactivated ([a45c9aae](https://github.com/abe33/minimap-pigments/commit/a45c9aaef130d3285ecf10cc2b5d178f22fd9a6b)) 49 | 50 | 51 | # v0.1.3 (2015-08-05) 52 | 53 | ## :bug: Bug Fixes 54 | 55 | - Fix persisting reference to pigments after package deactivation ([5f134ece](https://github.com/abe33/minimap-pigments/commit/5f134ece622768bdbf2ee503a53609dd0bc8c55f), [abe33/atom-pigments#66](https://github.com/abe33/atom-pigments/issues/66)) 56 | 57 | 58 | # v0.1.2 (2015-07-22) 59 | 60 | ## :bug: Bug Fixes 61 | 62 | - Fix decorations not destroyed on deactivation ([0c484598](https://github.com/abe33/minimap-pigments/commit/0c4845986cbd336ed982a2f266b7dd3d4285daab)) 63 | 64 | 65 | # v0.1.1 (2015-06-09) 66 | 67 | ## :bug: Bug Fixes 68 | 69 | - Fix markers persisting after tokenisation when they should have been hidden ([b0314408](https://github.com/abe33/minimap-pigments/commit/b0314408590b53f93734d66b5f7ce96dd265bfc3)) 70 | 71 | 72 | # v0.1.0 (2015-06-04) 73 | 74 | ## :sparkles: Features 75 | 76 | First public version that displays pigments colors in the Minimap. 77 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minimap-pigments package [![Build Status](https://travis-ci.org/abe33/minimap-pigments.svg?branch=master)](https://travis-ci.org/abe33/minimap-pigments) 2 | 3 | An Atom plugin to display pigments colors in the Minimap. 4 | 5 | ![Screenshot](https://github.com/abe33/minimap-pigments/blob/master/screenshot.png?raw=true) 6 | -------------------------------------------------------------------------------- /ci/build-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Downloading node v0.10.22..." 4 | curl -s -O http://nodejs.org/dist/v0.10.22/node-v0.10.22-darwin-x64.tar.gz 5 | tar -zxf node-v0.10.22-darwin-x64.tar.gz 6 | export PATH=$PATH:$PWD/node-v0.10.22-darwin-x64/bin 7 | 8 | echo "Downloading latest Atom release..." 9 | curl -s -L "https://atom.io/download/mac" \ 10 | -H 'Accept: application/octet-stream' \ 11 | -o atom.zip 12 | 13 | mkdir atom 14 | unzip -q atom.zip -d atom 15 | 16 | echo "Downloading latest Minimap release..." 17 | atom/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm install minimap 18 | 19 | echo "Downloading latest Pigments release..." 20 | atom/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm install pigments 21 | 22 | echo "Downloading package dependencies..." 23 | atom/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm install 24 | 25 | echo "Running specs..." 26 | ATOM_PATH=./atom atom/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm test --path atom/Atom.app/Contents/Resources/app/atom.sh 27 | 28 | exit 29 | -------------------------------------------------------------------------------- /lib/minimap-pigments-binding.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable} = require 'atom' 2 | 3 | module.exports = 4 | class MinimapPigmentsBinding 5 | constructor: ({@editor, @minimap, @colorBuffer}) -> 6 | @displayedMarkers = [] 7 | @decorationsByMarkerId = {} 8 | @subscriptionsByMarkerId = {} 9 | 10 | @subscriptions = new CompositeDisposable 11 | 12 | @colorBuffer.initialize().then => @updateMarkers() 13 | 14 | if @colorBuffer.editor.onDidTokenize? 15 | @subscriptions.add @colorBuffer.editor.onDidTokenize => 16 | @updateMarkers() 17 | else 18 | @subscriptions.add @colorBuffer.editor.displayBuffer.onDidTokenize => 19 | @updateMarkers() 20 | 21 | @subscriptions.add @colorBuffer.onDidUpdateColorMarkers => 22 | @updateMarkers() 23 | 24 | @decorations = [] 25 | 26 | updateMarkers: -> 27 | markers = @colorBuffer.findValidColorMarkers() 28 | 29 | for m in @displayedMarkers when m not in markers 30 | @decorationsByMarkerId[m.id]?.destroy() 31 | 32 | for m in markers when m.color?.isValid() and m not in @displayedMarkers 33 | decoration = @minimap.decorateMarker(m.marker, type: 'highlight', color: m.color.toCSS(), plugin: 'pigments') 34 | 35 | @decorationsByMarkerId[m.id] = decoration 36 | @subscriptionsByMarkerId[m.id] = decoration.onDidDestroy => 37 | @subscriptionsByMarkerId[m.id]?.dispose() 38 | delete @subscriptionsByMarkerId[m.id] 39 | delete @decorationsByMarkerId[m.id] 40 | 41 | @displayedMarkers = markers 42 | 43 | destroy: -> 44 | @destroyDecorations() 45 | @subscriptions.dispose() 46 | 47 | destroyDecorations: -> 48 | sub?.dispose() for id,sub of @subscriptionsByMarkerId 49 | decoration?.destroy() for id,decoration of @decorationsByMarkerId 50 | 51 | @decorationsByMarkerId = {} 52 | @subscriptionsByMarkerId = {} 53 | -------------------------------------------------------------------------------- /lib/minimap-pigments.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable} = require 'event-kit' 2 | MinimapPigmentsBinding = require './minimap-pigments-binding' 3 | 4 | module.exports = 5 | active: false 6 | 7 | isActive: -> @active 8 | 9 | activate: (state) -> 10 | @bindingsById = {} 11 | @subscriptionsById = {} 12 | @subscriptions = new CompositeDisposable 13 | 14 | consumeMinimapServiceV1: (@minimap) -> 15 | @minimap.registerPlugin 'pigments', this 16 | 17 | consumePigmentsServiceV1: (@pigments) -> 18 | @subscriptions.add @pigments.getProject().onDidDestroy => @pigments = null 19 | 20 | @initializeBindings() if @minimap? and @active 21 | 22 | deactivate: -> 23 | @subscriptions.dispose() 24 | @editorsSubscription.dispose() 25 | @minimap.unregisterPlugin 'pigments' 26 | @minimap = null 27 | @pigments = null 28 | 29 | activatePlugin: -> 30 | return if @active 31 | 32 | @active = true 33 | 34 | @initializeBindings() if @pigments? 35 | 36 | initializeBindings: -> 37 | @editorsSubscription = @pigments.observeColorBuffers (colorBuffer) => 38 | editor = colorBuffer.editor 39 | minimap = @minimap.minimapForEditor(editor) 40 | 41 | binding = new MinimapPigmentsBinding({editor, minimap, colorBuffer}) 42 | @bindingsById[editor.id] = binding 43 | 44 | @subscriptionsById[editor.id] = editor.onDidDestroy => 45 | @subscriptionsById[editor.id]?.dispose() 46 | binding.destroy() 47 | delete @subscriptionsById[editor.id] 48 | delete @bindingsById[editor.id] 49 | 50 | bindingForEditor: (editor) -> 51 | return @bindingsById[editor.id] if @bindingsById[editor.id]? 52 | 53 | deactivatePlugin: -> 54 | return unless @active 55 | 56 | binding.destroy() for id,binding of @bindingsById 57 | 58 | @active = false 59 | @editorsSubscription?.dispose() 60 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimap-pigments", 3 | "main": "./lib/minimap-pigments", 4 | "version": "0.2.2", 5 | "description": "An Atom plugin to display pigments colors in the Minimap.", 6 | "repository": "https://github.com/abe33/minimap-pigments", 7 | "license": "MIT", 8 | "engines": { 9 | "atom": ">0.50.0" 10 | }, 11 | "keywords": [ 12 | "minimap", 13 | "pigments", 14 | "colors", 15 | "palette" 16 | ], 17 | "consumedServices": { 18 | "minimap": { 19 | "versions": { 20 | "1.0.0": "consumeMinimapServiceV1" 21 | } 22 | }, 23 | "pigments.api": { 24 | "versions": { 25 | "1.0.0": "consumePigmentsServiceV1" 26 | } 27 | } 28 | }, 29 | "dependencies": { 30 | "event-kit": ">= 0.7.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abe33/minimap-pigments/c9d9aecf71c46ad5c6be4f696b51f6e04dd0fef5/screenshot.png -------------------------------------------------------------------------------- /spec/fixtures/sample.sass: -------------------------------------------------------------------------------- 1 | 2 | body 3 | background: red 4 | color: blue 5 | -------------------------------------------------------------------------------- /spec/minimap-pigments-spec.coffee: -------------------------------------------------------------------------------- 1 | MinimapPigments = require '../lib/minimap-pigments' 2 | 3 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 4 | # 5 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 6 | # or `fdescribe`). Remove the `f` to unfocus the block. 7 | 8 | describe "MinimapPigments", -> 9 | [workspaceElement, editor, minimapPackage, minimap, pigmentsProject, colorBuffer, plugin, binding] = [] 10 | 11 | editBuffer = (text, options={}) -> 12 | if options.start? 13 | if options.end? 14 | range = [options.start, options.end] 15 | else 16 | range = [options.start, options.start] 17 | 18 | editor.setSelectedBufferRange(range) 19 | 20 | editor.insertText(text) 21 | editor.getBuffer().emitter.emit('did-stop-changing') unless options.noEvent 22 | 23 | beforeEach -> 24 | workspaceElement = atom.views.getView(atom.workspace) 25 | jasmine.attachToDOM(workspaceElement) 26 | 27 | waitsForPromise -> 28 | atom.workspace.open('sample.sass').then (textEditor) -> 29 | editor = textEditor 30 | 31 | waitsForPromise -> 32 | atom.packages.activatePackage('pigments').then (pkg) -> 33 | pigmentsProject = pkg.mainModule.getProject() 34 | 35 | waitsForPromise -> 36 | atom.packages.activatePackage('minimap').then (pkg) -> 37 | minimapPackage = pkg.mainModule 38 | 39 | waitsForPromise -> 40 | atom.packages.activatePackage('minimap-pigments').then (pkg) -> 41 | plugin = pkg.mainModule 42 | 43 | runs -> 44 | minimap = minimapPackage.minimapForEditor(editor) 45 | colorBuffer = pigmentsProject.colorBufferForEditor(editor) 46 | 47 | waitsFor -> 48 | binding = plugin.bindingForEditor(editor) 49 | 50 | runs -> 51 | spyOn(minimap, 'decorateMarker').andCallThrough() 52 | 53 | describe "with an open editor that have a minimap", -> 54 | beforeEach -> 55 | waitsForPromise -> colorBuffer.initialize() 56 | 57 | it "creates a binding between the two plugins", -> 58 | expect(binding).toBeDefined() 59 | 60 | it 'decorates the minimap with color markers', -> 61 | expect(minimap.decorateMarker).toHaveBeenCalled() 62 | 63 | describe 'when a color is added', -> 64 | beforeEach -> 65 | editor.moveToBottom() 66 | editBuffer(' border-color: yellow') 67 | 68 | waitsFor -> minimap.decorateMarker.callCount > 2 69 | 70 | it 'adds a new decoration on the minimap', -> 71 | expect(minimap.decorateMarker.callCount).toEqual(3) 72 | 73 | describe 'when a color is removed', -> 74 | beforeEach -> 75 | spyOn(minimap, 'removeAllDecorationsForMarker').andCallThrough() 76 | 77 | editBuffer('', start: [2,0], end: [2, Infinity]) 78 | 79 | waitsFor -> minimap.removeAllDecorationsForMarker.callCount > 0 80 | 81 | it 'removes the minimap decoration', -> 82 | expect(minimap.removeAllDecorationsForMarker.callCount).toEqual(1) 83 | 84 | describe 'when the editor is destroyed', -> 85 | beforeEach -> 86 | spyOn(binding, 'destroy').andCallThrough() 87 | editor.destroy() 88 | 89 | it 'also destroy the binding model', -> 90 | expect(binding.destroy).toHaveBeenCalled() 91 | 92 | expect(plugin.bindingForEditor(editor)).toBeUndefined() 93 | 94 | describe 'when the plugin is deactivated', -> 95 | beforeEach -> 96 | spyOn(binding, 'destroy').andCallThrough() 97 | 98 | plugin.deactivatePlugin() 99 | 100 | it 'removes all the decorations from the minimap', -> 101 | expect(binding.destroy).toHaveBeenCalled() 102 | -------------------------------------------------------------------------------- /styles/minimap-pigments.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/stylesheets/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | --------------------------------------------------------------------------------