• Stars
    star
    522
  • Rank 84,811 (Top 2 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Atom package to display colors in project and files.

Build Status

A package to display colors in project and files:

Screenshot

Pigments will scan source files in your project directories looking for colors and will build a palette with all of them. Then for each opened file, it will use the palette to evaluate the value of a given color. The legible source paths can be defined through various settings either at the global or per project level. By default colors in every file will be highlighted, to limit the display of colors to the desired filetype only please see the Defining Where Pigments Applies below.

Pigments supports out of the box most of the color transformations functions and expressions of the three biggest CSS pre-processors out there, namely LESS, Sass and Stylus. However, it doesn't mean pigments is able to parse and understand all of these languages constructs. For the moment, Pigments' aim is to support the widest range of usage, even if it implies reducing its ability to parse certain complex constructs. You can refer to the parser specs for an exhaustive list of the supported expressions.

Contributor note

This is a small note from one of the contributors. As of the time of writing, @abe33 (the creator of this amazing package) hasn't done any work on this repo for over 6 months. It seems he is focused on other projects. In the meantime, I've been trying to keep the issues clear and tagged and to close duplicates. However, I don't know enough about this project (or Atom plugins in general) to be able to fix any issues. If you think you are able to handle this project, please let Charlie (@Cxarli) or Cédric (@abe33) know, so we could help you help this project.

Please also see this masterpost.

Install

Using apm:

apm install pigments

Or search for pigments in Atom settings view.

Defining Where Pigments Applies

By default, Pigments will highlight every color in every file, but you can limit that using the two settings Supported Filetypes and Ignored Scopes.

The first setting allow you to specify the list of extensions where pigments will apply. For instance, by using the values css, less, colors will be visible only in CSS and Less files.

The second setting takes an array of regular expression strings used to exclude colors in specific scopes (like comments or strings). You can find the scope that applies at the cursor position with the Editor: Log Cursor Scope command (cmd-alt-p or ctrl-alt-shift-p).

get scope

Defaults File

Pigments is able to follow variables uses up to a certain point, if a color refers to several variables whose values can't be evaluated (because they use unsupported language-specific features) the color will be flagged as invalid and not displayed. This can be problematic when it happens on the core components of a complex palette.

To solve that issue, you can define a defaults file named .pigments at the root of a project directory and you can put in it all the variables declarations to use if a value from the sources files can't be evaluated.

This can also be used when your project core palette is dynamically defined so that pigments can evaluate properly the rest of the project colors.

Commands

Note: Pigments doesn't define any keybindings for the provided commands, instead it'll let you define your own keybindings.

Pigments: Show Palette

You can display the project's palette through the Pigments: Show Palette command from the command palette:

Screenshot

The project palette is made of all the colors that are affected to a variable, which means it won't display hardcoded colors affected to a CSS property. If you want to find every color used in a project, including the hardcoded colors in CSS files, use the Pigments: Find Colors instead.

Patterns for Less, Sass, Scss and Stylus variables are currently supported, which includes:

my-var = #123456 // stylus
$my-var: #123456 // sass
$my-var: #123456; // scss
@my-var: #123456; /* less */

As with every command, this command can be triggered using the keyboard by defining a keybinding like this:

'atom-workspace':
  'alt-shift-p': 'pigments:show-palette'

Pigments: Find Colors

You can search for all colors in your project using the Pigments: Find Colors command from the command palette:

Screenshot

The results will include colors declared in variables, places where the color variables are used as well as hardcoded color values in every file that matches one of the patterns defined in both pigments.sourceNames and pigments.extendedSearchNames settings.

By default this includes:

**/*.css
**/*.less
**/*.scss
**/*.sass
**/*.styl
**/*.stylus

This command can be triggered using the keyboard by defining a keybinding like this:

'atom-workspace':
  'alt-shift-f': 'pigments:find-colors'

Pigments: Convert To *

It evaluates and replace a color by the corresponding notation. Accessible from the command palette or by right clicking on a color.

pigments-conversion

These commands can be triggered using the keyboard by defining a keybinding like this:

'atom-workspace':
  'alt-shift-h': 'pigments:convert-to-hex'
  'alt-shift-g': 'pigments:convert-to-rgb'
  'alt-shift-j': 'pigments:convert-to-rgba'
  'alt-shift-k': 'pigments:convert-to-hsl'
  'alt-shift-l': 'pigments:convert-to-hsla'

When triggered from the command palette or from the keyboard, the conversion will operate on every cursor positioned on color markers.

Pigments: Project Settings

Each Pigments project has its own set of settings that can extend or replace the global configuration. These settings are available through the pigments:project-settings command:

pigments-conversion

The Source Names, Ignored Names, Ignored Scopes and Extended Search Names fields all match a global configuration. When defined the project will use both the global config and the one of the current project, except when the Ignore Global checkbox is checked.

The Include Atom Themes Stylesheets setting is specific to the project and can't be defined globally. When enabled, it'll add all the public themes variables in the current project palette:

pigments-conversion

Note that it won't add all the variables defined in the less files of the syntax and ui themes, only the ones that must be present as defined in the themes documentation.

This feature is still quite experimental at this stage.

Pigments: Reload

This command will force a reload of all variables in the project, this can be useful when the serialized state of the plugin contains invalid data and you want to get rid of them without having to touch to the content of the .atom/storage directory.

This command can be triggered using the keyboard by defining a keybinding like this:

'atom-workspace':
  'alt-shift-r': 'pigments:reload'

Settings

Source Names

An array of glob patterns of the files to use as source for the project's variables and colors.

  • Key: pigments.sourceNames
  • Default: ['**/*.styl', '**/*.stylus', '**/*.less', '**/*.sass', '**/*.scss']

Ignored Names

An array of glob patterns of the files to ignore as source files for the project's variables and colors.

  • Key: pigments.ignoredNames
  • Default: ['node_modules/*']

Extended Search Names

An array of glob patterns of files to include in the Pigments: Find Colors scanning process.

  • Key: pigments.extendedSearchNames
  • Default: ['**/*.css']

Supported Filetypes

An array of file extensions where colors will be highlighted. If the wildcard * is present in this array then colors in every file will be highlighted.

  • Key: pigments.supportedFiletypes
  • Default: ['*']

Filetypes For Color Words

An array of file extensions where color values such as red, azure or whitesmoke will be highlighted. By default CSS and CSS pre-processors files are supported.

You can use none or whatever value that doesn't match a file extension to completely prevent color words from being highlighted.

  • Key: pigments.filetypesForColorWords
  • Default: ['css', 'less', 'styl', 'stylus', 'sass', 'scss']

Ignored Scopes

An array of regular expressions strings to match scopes to ignore when rendering colors in a text editor.

For instance, if you want to ignore colors in comments and strings in your source files, use the following value:

\.comment, \.string

As you can notice, the . character in scopes are escaped. This is due to the fact that this setting uses javascript RegExp to test the token's scope and the . is used to match against any character.

For instance, to ignore colors in html attributes you can use the following expression:

\.text\.html(.*)\.string

Note the (.*) in the middle of the expression. It'll ensure that we're searching for the .string scope in the .text.html grammar even if there's other scope between them by catching any character between the two classnames.

To find which scope is applied at a given position in a buffer you can use the editor:log-cursor-scope command. From that you'll be able to determine what expression to use to match the scope.

  • Key: pigments.ignoredScopes
  • Default: []

Autocomplete Scopes

The autocomplete provider will only complete color names in editors whose scope is present in this list.

  • Key: pigments.autocompleteScopes
  • Default: ['.source.css', '.source.css.less', '.source.sass', '.source.css.scss', '.source.stylus']

Sass Shade And Tint Implementation

Sass doesn't provide any implementation for shade and tint function, and Compass and Bourbon have different implementation for these two methods. This setting allow you to chose which implementation to use.

  • Key: pigments.sassShadeAndTintImplementation
  • Default: 'compass'

Extend Autocomplete To Variables

When enabled, the autocomplete provider will also provides completion for non-color variables.

  • Key: pigments.extendAutocompleteToVariables
  • Default: false

Extend Autocomplete To Color Value

When enabled, the autocomplete provider will also provides color value.

  • Key: pigments.extendAutocompleteToColorValue
  • Default: false

Traverse Into Symlink Directories

Whether to traverse symlinked directories to find source files or not.

  • Key: pigments.traverseIntoSymlinkDirectories
  • Default: false

Ignore VCS Ignored Paths

When this setting is enabled, every file that are ignored by the VCS will also be ignored in Pigments. That means they'll be excluded when searching for colors and when building the project palette.

  • Key: pigments.ignoreVcsIgnoredPaths
  • Default: true

Marker Type

Defines the render mode of color markers. The possible values are:

background outline underline
dot square-dot gutter
  • Key: pigments.markerType
  • Default: 'background'

Sort Palette Colors

The type of sorting applied to the colors in the palette view. It can be changed directly from the palette view.

  • Key: pigments.sortPaletteColors
  • Default: 'none'

Group Palette Colors

Defines how the colors are grouped together in the palette view. It can be changed directly from the palette view.

  • Key: pigments.groupPaletteColors
  • Default: 'none'

Merge Duplicates

Defines whether to merge colors duplicates together as a single result in the palette view. It can be changed directly from the palette view.

  • Key: pigments.mergeDuplicates
  • Default: false

Delay Before Scan

Pigments rescans the text buffer once you stopped editing it, however as the process can be sometime expensive, it'll apply an extra delay after the dispatch of the did-stop-changing event before starting the scanning process. This setting define the number of milliseconds to wait after the did-stop-changing event before starting to scan the buffer again. If your start typing in the buffer again in this interval, the rescan process will be aborted.

  • Key: pigments.delayBeforeScan
  • Default: 500 (ms)

More Repositories

1

atom-tablr

Edit CSV files using a table editor
CoffeeScript
165
star
2

atom-color-highlight

Highlights color declarations in files
CoffeeScript
79
star
3

atom-bezier-curve-editor

CoffeeScript
78
star
4

spectacular

Advanced BDD framework for CoffeeScript and JavaScript
CoffeeScript
73
star
5

minimap-pigments

An Atom plugin to display pigments colors in the Minimap
CoffeeScript
15
star
6

atom-figlet

Converts a selection into ascii-art using figlet
CoffeeScript
15
star
7

Abe-AS3-Lib

A multi-purpose ActionScript Library.
ActionScript
12
star
8

atom-tree-view-breadcrumb

Display a breadcrumb on tree view scroll
CoffeeScript
10
star
9

atom-project-palette-finder

Finds and archives colors defined in a project's less/sass/stylus files
CoffeeScript
10
star
10

changelog-gen

Small Utility to generates Changelog files
JavaScript
9
star
11

atom-utils

A bunch of general purpose utilities for Atom packages
CoffeeScript
9
star
12

atom-unfancy-file-icons

My file icons stylesheet as a package
CSS
6
star
13

pigments

A color model for atom packages
CoffeeScript
6
star
14

typography-fixer

Check or fix strings according to typographic rules
JavaScript
5
star
15

ludumdare24

Our Jam Submission for the ludumdare
ActionScript
5
star
16

minimap-color-highlight

A minimap binding for the atom-color-highlight package
CoffeeScript
5
star
17

hamcrest4qunit

Hamcrest matchers for QUnit
JavaScript
5
star
18

uninstallable

A package that shouldn't be installed until atom reach version 99.0.0.
CoffeeScript
3
star
19

unupdatable

A package whose latest version shouldn't be installed until Atom reach version 99.0.0
CoffeeScript
3
star
20

awesome_form

Yet another form handler for rails
CoffeeScript
3
star
21

CoffeeScript-Signal

A Signal implementation in coffeescript
JavaScript
3
star
22

prolix

A debug and benchmarking mixin for atom modules
3
star
23

atom-react-minimap

A rework of the atom minimap as a React component
CoffeeScript
3
star
24

Abe-Python-Lib

Some Django application used in my daily work
JavaScript
3
star
25

neat

A command line tool for coffeescript and nodejs projects inspired by rails
CoffeeScript
3
star
26

widjet

A simple and lightweight widget helper for the web
JavaScript
2
star
27

widjet-select-multiple

A widget to make multiple select more user friendly
JavaScript
2
star
28

Widgets.coffee

A widget system in coffeescript.
CoffeeScript
2
star
29

Abe-JS-Lib

2
star
30

atom-js-package-sample

Because people need proofs.
JavaScript
2
star
31

chancejs

Various pseudo-random implementations packaged with helpful random utilities
CoffeeScript
2
star
32

particlejs

Javascript particles engine
CoffeeScript
2
star
33

django-babelfish

Localizing content of django applications made as easy as putting a fish in your ear ;)
Python
2
star
34

atom-minimap-symbols

Displays symbols on the minimap
CoffeeScript
1
star
35

agt

CoffeeScript
1
star
36

widjet-text-editor

A widjet to edit rich text in a textarea
JavaScript
1
star
37

geomjs

A bunch of geometry utilities for javascript (browser or nodejs)
CoffeeScript
1
star
38

express_neat

Express integration for Neat
CoffeeScript
1
star
39

widjet-file-upload

A widget to display and upload files in a form
JavaScript
1
star
40

widjet-validation

A form validation widget for widjet
JavaScript
1
star
41

awesome_form_bootstrap

Bootstrap theme for AwesomeForm
Ruby
1
star
42

piros-website

Piros Website
CoffeeScript
1
star
43

atom-plugin

Atom package for Kite
JavaScript
1
star
44

chord-viewer

Chord viewer for HTML pages
JavaScript
1
star
45

widjet-disposables

Lightweight disposable pattern implementation
JavaScript
1
star
46

sg

JavaScript
1
star
47

portfolio

1
star
48

widjet-theme-light

A sets of styles for widjet enhanced forms
Sass
1
star
49

widjet-json-form

A widget to generate forms using a json object descriptor
JavaScript
1
star
50

widjet-daterange-picker

Date range picker component for Widjet
JavaScript
1
star
51

spectacular_rails

Rails binding for Spectacular
Ruby
1
star
52

widjet-test-utils

A bunch of test utilities for widjet plugins
JavaScript
1
star
53

widjet-transferable

A drag and drop widget for widjet
JavaScript
1
star
54

atom-sample-minimap-plugin

A sample minimap plugin
CoffeeScript
1
star
55

atom-smart-tag-cycle

Wraps the cursor with a tag or cycle between the existing tags in a buffer
CoffeeScript
1
star
56

customs

We gotta take the power back
Ruby
1
star
57

widjet-utils

JS utilities for widjet
JavaScript
1
star
58

mixinsjs

A Module/Mixin javascript implementation with various useful mixins
JavaScript
1
star
59

typrocessor

A versatile typographic cleaning processor for ruby
Ruby
1
star
60

atom-multiple-cursors-clipboard

Monkey patch Atom to offer proper multi-cursors clipboard handling
CoffeeScript
1
star
61

rollup-test

Test of rollup.js bundling utility
JavaScript
1
star
62

autocomplete

Advanced autocomplete UI and engine with an API to support adding any language.
CoffeeScript
1
star
63

stylus_playground

CSS
1
star