Merge branch 'master' of github.com:Glavin001/atom-beautify into better-settings

This commit is contained in:
Glavin Wiechert 2016-03-29 14:41:43 -03:00
commit 232a91bb20
13 changed files with 742 additions and 3 deletions

View File

@ -3,9 +3,11 @@
- Add [clang-format](http://clang.llvm.org/docs/ClangFormat.html) beautifier for C/C++/Obj-C languages.
- Add [yapf](http://github.com/google/yapf) beautifier for Python.
- Closes [#776] (https://github.com/Glavin001/atom-beautify/issues/776) Add support for `collapse-preserve-inline` brace_style for javascript.
- Closes [#786](https://github.com/Glavin001/atom-beautify/issues/786) YAPF configuration files are ignored.
# v0.29.0
- Closes [#447](https://github.com/Glavin001/atom-beautify/issues/447). Improved Handlebars language support
- Closes [#384](https://github.com/Glavin001/atom-beautify/issues/384). Add [latexindent.pl](https://github.com/cmhughes/latexindent.pl) beautifier for LaTeX language
# v0.26.0 (2015-05-03)
- Closes [#176](https://github.com/Glavin001/atom-beautify/issues/176). Add [gofmt](http://golang.org/cmd/gofmt/) beautifier for Go language

View File

@ -4969,6 +4969,250 @@ Wrap lines at next opportunity after N characters (Supported by Pretty Diff)
}
```
#### [LaTeX](#latex)
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Options for language LaTeX
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable LaTeX Beautification
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Disable Beautifying Language*" and change it to your desired configuration.
##### [Default Beautifier](#default-beautifier)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `Latex Beautify`
**Type**: `string`
**Enum**: `Latex Beautify`
**Description**:
Default Beautifier to be used for LaTeX
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Default Beautifier*" and change it to your desired configuration.
##### [Beautify On Save](#beautify-on-save)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Automatically beautify LaTeX files on save
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Beautify On Save*" and change it to your desired configuration.
##### [Align columns in environments](#align-columns-in-environments)
**Namespace**: `latex`
**Key**: `align_columns_in_environments`
**Default**: `tabular,matrix,bmatrix,pmatrix`
**Type**: `array`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
undefined (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"align_columns_in_environments": [
"tabular",
"matrix",
"bmatrix",
"pmatrix"
]
}
}
```
##### [Always look for split braces](#always-look-for-split-braces)
**Namespace**: `latex`
**Key**: `always_look_for_split_braces`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
If `latexindent` should look for commands that split braces across lines (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"always_look_for_split_braces": true
}
}
```
##### [Always look for split brackets](#always-look-for-split-brackets)
**Namespace**: `latex`
**Key**: `always_look_for_split_brackets`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
If `latexindent` should look for commands that split brackets across lines (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"always_look_for_split_brackets": false
}
}
```
##### [Indent char](#indent-char)
**Namespace**: `latex`
**Key**: `indent_char`
**Default**: ` `
**Type**: `string`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Indentation character (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"indent_char": " "
}
}
```
##### [Indent preamble](#indent-preamble)
**Namespace**: `latex`
**Key**: `indent_preamble`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Indent the preable (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"indent_preamble": false
}
}
```
##### [Indent with tabs](#indent-with-tabs)
**Namespace**: `latex`
**Key**: `indent_with_tabs`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"indent_with_tabs": true
}
}
```
##### [Remove trailing whitespace](#remove-trailing-whitespace)
**Namespace**: `latex`
**Key**: `remove_trailing_whitespace`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Remove trailing whitespace (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"remove_trailing_whitespace": false
}
}
```
#### [LESS](#less)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
@ -12152,6 +12396,190 @@ If a terminating comma should be inserted into arrays, object literals, and dest
```
### Latex Beautify
##### [Indent char](#indent-char)
**Namespace**: `latex`
**Key**: `indent_char`
**Default**: ` `
**Type**: `string`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Indentation character (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"indent_char": " "
}
}
```
##### [Indent with tabs](#indent-with-tabs)
**Namespace**: `latex`
**Key**: `indent_with_tabs`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"indent_with_tabs": true
}
}
```
##### [Indent preamble](#indent-preamble)
**Namespace**: `latex`
**Key**: `indent_preamble`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Indent the preable (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"indent_preamble": false
}
}
```
##### [Always look for split braces](#always-look-for-split-braces)
**Namespace**: `latex`
**Key**: `always_look_for_split_braces`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
If `latexindent` should look for commands that split braces across lines (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"always_look_for_split_braces": true
}
}
```
##### [Always look for split brackets](#always-look-for-split-brackets)
**Namespace**: `latex`
**Key**: `always_look_for_split_brackets`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
If `latexindent` should look for commands that split brackets across lines (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"always_look_for_split_brackets": false
}
}
```
##### [Remove trailing whitespace](#remove-trailing-whitespace)
**Namespace**: `latex`
**Key**: `remove_trailing_whitespace`
**Type**: `boolean`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
Remove trailing whitespace (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"remove_trailing_whitespace": false
}
}
```
##### [Align columns in environments](#align-columns-in-environments)
**Namespace**: `latex`
**Key**: `align_columns_in_environments`
**Default**: `tabular,matrix,bmatrix,pmatrix`
**Type**: `array`
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
**Description**:
undefined (Supported by Latex Beautify)
**Example `.jsbeautifyrc` Configuration**
```json
{
"latex": {
"align_columns_in_environments": [
"tabular",
"matrix",
"bmatrix",
"pmatrix"
]
}
}
```
### PHP-CS-Fixer
##### [PHP-CS-Fixer Path](#php-cs-fixer-path)

View File

@ -0,0 +1,5 @@
This is a sample.
\[
\int_0^1f(x)\, dx
\]
The above should be indented.

View File

@ -0,0 +1,5 @@
This is a sample.
\[
\int_0^1f(x)\, dx
\]
The above should be indented.

View File

@ -0,0 +1,77 @@
__kernel void reduce_min(__global const int* A, __global int* B, __local int* scratch) {
//Get local variable data
int id = get_global_id(0);
int lid = get_local_id(0);
int N = get_local_size(0);
//Store valus of global memory into local memory
scratch[lid] = A[id];
//Wait for copying to complete
barrier(CLK_LOCAL_MEM_FENCE);
for (int i = 1; i < N; i *= 2) {
if (!(lid % (i * 2)) && ((lid + i) < N)){
if (scratch[lid] > scratch[lid + i])
scratch[lid] = scratch[lid+i];
}
barrier(CLK_LOCAL_MEM_FENCE);
}
//Store cache in output array
if (!lid)
atomic_min(&B[0], scratch[lid]);
}
__kernel void reduce_max(__global const int* A, __global int* B, __local int* scratch) {
//Get local variable data
int id = get_global_id(0);
int lid = get_local_id(0);
int N = get_local_size(0);
//Store valus of global memory into local memory
scratch[lid] = A[id];
//Wait for copying to complete
barrier(CLK_LOCAL_MEM_FENCE);
for (int i = 1; i < N; i *= 2) {
if (!(lid % (i * 2)) && ((lid + i) < N)){
if (scratch[lid] < scratch[lid + i])
scratch[lid] = scratch[lid+i];
}
barrier(CLK_LOCAL_MEM_FENCE);
}
//Store cache in output array
if (!lid)
atomic_max(&B[0], scratch[lid]);
}
__kernel void reduce_avg(__global const int* A, __global int* B, __local int* scratch) {
//Get local variable data
int id = get_global_id(0);
int lid = get_local_id(0);
int N = get_local_size(0);
//Store valus of global memory into local memory
scratch[lid] = A[id];
//Wait for copying to complete
barrier(CLK_LOCAL_MEM_FENCE);
for (int i = 1; i < N; i *= 2) {
if (!(lid % (i * 2)) && ((lid + i) < N))
{
scratch[lid] += scratch[lid+i];
}
barrier(CLK_LOCAL_MEM_FENCE);
}
//Store cache in output array
if (!lid)
atomic_add(&B[0],scratch[lid]);
}

View File

@ -0,0 +1,77 @@
__kernel void reduce_min(__global const int* A, __global int* B, __local int* scratch) {
//Get local variable data
int id = get_global_id(0);
int lid = get_local_id(0);
int N = get_local_size(0);
//Store valus of global memory into local memory
scratch[lid] = A[id];
//Wait for copying to complete
barrier(CLK_LOCAL_MEM_FENCE);
for (int i = 1; i < N; i *= 2) {
if (!(lid % (i * 2)) && ((lid + i) < N)){
if (scratch[lid] > scratch[lid + i])
scratch[lid] = scratch[lid+i];
}
barrier(CLK_LOCAL_MEM_FENCE);
}
//Store cache in output array
if (!lid)
atomic_min(&B[0], scratch[lid]);
}
__kernel void reduce_max(__global const int* A, __global int* B, __local int* scratch) {
//Get local variable data
int id = get_global_id(0);
int lid = get_local_id(0);
int N = get_local_size(0);
//Store valus of global memory into local memory
scratch[lid] = A[id];
//Wait for copying to complete
barrier(CLK_LOCAL_MEM_FENCE);
for (int i = 1; i < N; i *= 2) {
if (!(lid % (i * 2)) && ((lid + i) < N)){
if (scratch[lid] < scratch[lid + i])
scratch[lid] = scratch[lid+i];
}
barrier(CLK_LOCAL_MEM_FENCE);
}
//Store cache in output array
if (!lid)
atomic_max(&B[0], scratch[lid]);
}
__kernel void reduce_avg(__global const int* A, __global int* B, __local int* scratch) {
//Get local variable data
int id = get_global_id(0);
int lid = get_local_id(0);
int N = get_local_size(0);
//Store valus of global memory into local memory
scratch[lid] = A[id];
//Wait for copying to complete
barrier(CLK_LOCAL_MEM_FENCE);
for (int i = 1; i < N; i *= 2) {
if (!(lid % (i * 2)) && ((lid + i) < N))
{
scratch[lid] += scratch[lid+i];
}
barrier(CLK_LOCAL_MEM_FENCE);
}
//Store cache in output array
if (!lid)
atomic_add(&B[0],scratch[lid]);
}

View File

@ -1,7 +1,7 @@
{
"name": "atom-beautify",
"main": "./src/beautify",
"version": "0.28.26",
"version": "0.28.27",
"private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, and SQL in Atom",
"repository": {
@ -66,6 +66,14 @@
{
"name": "Luis Arias",
"url": "https://github.com/kaaloo"
},
{
"name": "Bati Sengul",
"url": "https://github.com/Focus"
},
{
"name": "Dheepak Krishnamurthy",
"url": "https://github.com/kdheepak89"
}
],
"engines": {
@ -84,7 +92,7 @@
"diff": "^2.1.0",
"editorconfig": "^0.12.2",
"event-kit": "^1.4.1",
"expand-home-dir": "0.0.2",
"expand-home-dir": "0.0.3",
"extend": "^3.0.0",
"gherkin": "2.12.2",
"handlebars": "^4.0.2",

View File

@ -44,6 +44,7 @@ module.exports = class Beautifiers extends EventEmitter
'csscomb'
'gherkin'
'gofmt'
'latex-beautify'
'fortran-beautifier'
'js-beautify'
'jscs'

View File

@ -0,0 +1,72 @@
"use strict"
Beautifier = require('./beautifier')
path = require('path')
fs = require("fs")
temp = require("temp").track()
module.exports = class LatexBeautify extends Beautifier
name: "Latex Beautify"
options: {
LaTeX: true
}
# There are too many options with latexmk, I have tried to slim this down to the most useful ones.
# This method creates a configuration file for latexindent.
buildConfigFile: (options) ->
indentChar = options.indent_char
if options.indent_with_tabs
indentChar = "\\t"
# +true = 1 and +false = 0
config = """
defaultIndent: \"#{indentChar}\"
alwaysLookforSplitBraces: #{+options.always_look_for_split_braces}
alwaysLookforSplitBrackets: #{+options.always_look_for_split_brackets}
indentPreamble: #{+options.indent_preamble}
removeTrailingWhitespace: #{+options.remove_trailing_whitespace}
lookForAlignDelims:\n
"""
for delim in options.align_columns_in_environments
config += "\t#{delim}: 1\n"
return config
# Latexindent accepts configuration _files_ only.
# This file has to be named localSettings.yaml and be in the same folder as the tex file.
# It also insists on creating a log file somewhere.
# So we set up a directory with all the files in place.
setUpDir: (dirPath, text, config) ->
@texFile = path.join(dirPath, "latex.tex")
fs.writeFile @texFile, text, (err) ->
return reject(err) if err
@configFile = path.join(dirPath, "localSettings.yaml")
fs.writeFile @configFile, config, (err) ->
return reject(err) if err
@logFile = path.join(dirPath, "indent.log")
fs.writeFile @logFile, "", (err) ->
return reject(err) if err
#Beautifier does not currently have a method for creating directories, so we call temp directly.
beautify: (text, language, options) ->
new @Promise((resolve, reject) ->
temp.mkdir("latex", (err, dirPath) ->
return reject(err) if err
resolve(dirPath)
)
)
.then((dirPath)=>
@setUpDir(dirPath, text, @buildConfigFile(options))
run = @run "latexindent", [
"-o" #Output to the same location as file, -w creates a backup file, whereas this does not
"-s" #Silent mode
"-l" #Tell latexindent we have a local configuration file
"-c=" + dirPath #Tell latexindent to place the log file in this directory
@texFile
@texFile
], help: {
link: "https://github.com/cmhughes/latexindent.pl"
}
)
.then( =>
@readFile(@texFile)
)

View File

@ -16,7 +16,6 @@ module.exports = class Yapf extends Beautifier
beautify: (text, language, options) ->
@run("yapf", [
"-i"
["--style=pep8"]
tempFile = @tempFile("input", text)
], help: {
link: "https://github.com/google/yapf"

View File

@ -8,6 +8,7 @@ module.exports = {
###
grammars: [
"C"
"opencl"
]
###
@ -15,6 +16,7 @@ module.exports = {
###
extensions: [
"c"
"cl"
]
options:

View File

@ -36,6 +36,7 @@ module.exports = class Languages
"javascript"
"json"
"jsx"
"latex"
"less"
"markdown"
'marko'

View File

@ -0,0 +1,62 @@
# Get Atom defaults
scope = ['source.js']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "LaTeX"
namespace: "latex"
###
Supported Grammars
###
grammars: [
"LaTeX"
]
###
Supported extensions
###
extensions: [
"tex"
]
defaultBeautifier: "Latex Beautify"
###
###
options:
indent_char:
type: 'string'
default: defaultIndentChar
description: "Indentation character"
indent_with_tabs:
type: 'boolean'
default: true
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
indent_preamble:
type: 'boolean'
default: false
description: "Indent the preable"
always_look_for_split_braces:
type: 'boolean'
default: true
description: "If `latexindent` should look for commands that split braces across lines"
always_look_for_split_brackets:
type: 'boolean'
default: false
description: "If `latexindent` should look for commands that split brackets across lines"
remove_trailing_whitespace:
type: 'boolean'
default: false
description: "Remove trailing whitespace"
align_columns_in_environments:
type: 'array'
default:["tabular", "matrix", "bmatrix", "pmatrix"]
decription: "Aligns columns by the alignment tabs for environments specified"
}