Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Apr 9, 2016
0 parents commit 9673db9
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// A launch configuration that launches the extension inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false
}
]
}
7 changes: 7 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/**
typings/**
test/**
.editorconfig
.gitignore
.travis.yml
jsconfig.json
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# VS Code Post​CSS Sorting

> VS Code plugin to sort CSS rules content with specified order. Powered by [postcss-sorting](https://github.com/hudochenkov/postcss-sorting).
![2016-04-10_02-46-24](https://cloud.githubusercontent.com/assets/7034281/14407132/77dd07c4-fec6-11e5-8361-a47af434459c.gif)

## Install

To install, press `F1` and select `Extensions: Install Extensions` and then search for and select `postcss-sorting`.

## Usage

Press `F1` and run the command named `Post​CSS Sorting`.

## Keyboard shortcuts

For changes keyboard shortcuts, create a new rule in `File -> Preferences -> Keyboard Shortcuts`:

```json
{
"key": "ctrl+shift+c",
"command": "PostCSSSorting.processEditor"
}
```

## Options

You can override the default and user settings for individual projects. Just add an `PostCSSSorting` object to the `settings.json`file.

For example:

```json
{
"PostCSSSorting": {
"sort-order": ["padding", "margin"],
"sort-on-save": true
}
}
```

See the [postcss-sorting documentation](https://github.com/hudochenkov/postcss-sorting#options) for all rules and predefined configs.

## Changelog

See the [Releases section of our GitHub project](https://github.com/mrmlnc/vscode-attrs-sorter/releases) for changelogs for each release version.

## License

This software is released under the terms of the MIT license.
37 changes: 37 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

var vscode = require('vscode');
var postcss = require('postcss');
var postcssSorter = require('postcss-sorting');

function activate(context) {
var processEditor = vscode.commands.registerTextEditorCommand('PostCSSSorting.processEditor', function(textEditor) {
var options = Object.assign({
'sort-order': 'default',
'empty-lines-between-children-rules': 0,
'sort-on-save': false
}, vscode.workspace.getConfiguration('PostCSSSorting'));

var document = textEditor.document;
var documentText = document.getText();
var lastLine = document.lineAt(document.lineCount - 1);
var selectAll = new vscode.Range(0, 0, lastLine.lineNumber, lastLine.range.end.character);

postcss([postcssSorter(options)])
.process(documentText)
.then(function(result) {
textEditor.edit(function(editBuilder) {
editBuilder.replace(selectAll, result.css);
});
});
});

context.subscriptions.push(processEditor);
}

exports.activate = activate;

// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"noLib": true
},
"exclude": [
"node_modules"
]
}
67 changes: 67 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "vscode-postcss-sorting",
"displayName": "Post​CSS Sorting",
"description": "VS Code plugin to sort CSS rules content with specified order.",
"version": "1.0.0",
"publisher": "mrmlnc",
"engines": {
"vscode": "^0.10.10"
},
"icon": "icon.png",
"homepage": "https://github.com/mrmlnc/vscode-postcss-sorting",
"categories": [
"Other"
],
"activationEvents": [
"onCommand:PostCSSSorting.processEditor"
],
"main": "./extension",
"contributes": {
"commands": [{
"command": "PostCSSSorting.processEditor",
"title": "PostCSS Sorting"
}],
"configuration": {
"type": "object",
"title": "PostCSSSorting configuration",
"properties": {
"PostCSSSorting": {
"default": {},
"description": "Settings for PostCSS Sorting plugin"
}
}
}
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install"
},
"devDependencies": {
"vscode": "^0.11.0",
"xo": "^0.14.0"
},
"dependencies": {
"postcss": "^5.0.19",
"postcss-sorting": "^1.2.3"
},
"xo": {
"rules": {
"arrow-parens": [
2,
"always"
],
"object-curly-spacing": [
2,
"always"
],
"babel/object-curly-spacing": 0,
"space-before-function-paren": [
2,
"never"
]
},
"envs": [
"node",
"mocha"
]
}
}
1 change: 1 addition & 0 deletions typings/node.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../node_modules/vscode/typings/node.d.ts" />
1 change: 1 addition & 0 deletions typings/vscode-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../node_modules/vscode/typings/index-js.d.ts" />

0 comments on commit 9673db9

Please sign in to comment.