From 306dd569b4d77d6c1852238b80969742c91ceaf9 Mon Sep 17 00:00:00 2001 From: quilicicf Date: Tue, 27 Sep 2016 22:39:56 +0200 Subject: [PATCH] :new: Add indent_size capability for beautysh --- README.md | 2 +- docs/code/class/BashBeautify.html | 4 +- docs/code/extra/README.md.html | 2 +- docs/code/file/src/languages/bash.coffee.html | 26 +++++++++- docs/options.md | 52 ------------------- src/beautifiers/beautysh.coffee | 5 +- src/languages/bash.coffee | 12 +++++ 7 files changed, 45 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 4a77540..b8a0ba3 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ See [all supported options in the documentation at `docs/options.md`](https://g | --- | --- | --- | ---- | | Apex | `Apex` |`.cls`, `.trigger` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | | Arduino | `Arduino` |`.ino`, `.pde` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | -| Bash | `Shell script` |`.bash`, `.sh` | [`beautysh`](https://github.com/bemeurer/beautysh) (Default) | +| Bash | `Shell Script` |`.bash`, `.sh` | [`beautysh`](https://github.com/bemeurer/beautysh) (Default) | | C | `C`, `opencl` |`.h`, `.c`, `.cl` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | Coldfusion | `html` |`.cfm`, `.cfml`, `.cfc` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Clojure | `Clojure` |`.clj`, `.cljs`, `.edn` | [`cljfmt`](https://github.com/snoe/node-cljfmt) (Default) | diff --git a/docs/code/class/BashBeautify.html b/docs/code/class/BashBeautify.html index c8b5b04..3cfc98b 100644 --- a/docs/code/class/BashBeautify.html +++ b/docs/code/class/BashBeautify.html @@ -63,7 +63,9 @@
{
-  Bash: true
+  Bash: {
+    indent_size: true
+  }
 }
diff --git a/docs/code/extra/README.md.html b/docs/code/extra/README.md.html index bb3e359..9d6a562 100644 --- a/docs/code/extra/README.md.html +++ b/docs/code/extra/README.md.html @@ -119,7 +119,7 @@ Thank you.

Language Support

See beautysh (Default) diff --git a/docs/code/file/src/languages/bash.coffee.html b/docs/code/file/src/languages/bash.coffee.html index 846b4ff..48fec8b 100644 --- a/docs/code/file/src/languages/bash.coffee.html +++ b/docs/code/file/src/languages/bash.coffee.html @@ -39,6 +39,22 @@

Variables Summary

+
+ scope + = +
+
+
['source.sh', 'source.bash']
+ +
+
+ defaultIndentSize + = +
+
+
(softTabs ? tabLength : 1)
+ +
module.exports = @@ -57,7 +73,15 @@ /* Supported extensions */ - extensions: ["bash", "sh"] + extensions: ["bash", "sh"], + options: { + indent_size: { + type: 'integer', + "default": defaultIndentSize, + minimum: 0, + description: "Indentation size/length" + } + } } diff --git a/docs/options.md b/docs/options.md index 55de6cc..dfdc6ca 100644 --- a/docs/options.md +++ b/docs/options.md @@ -328,7 +328,6 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify) | `disabled` | :white_check_mark: | | `default_beautifier` | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | -| `configPath` | :white_check_mark: | **Description**: @@ -389,30 +388,6 @@ Automatically beautify Bash files on save 2. Go into *Packages* and search for "*Atom Beautify*" package. 3. Find the option "*Beautify On Save*" and change it to your desired configuration. -##### [Config Path](#config-path) - -**Namespace**: `bash` - -**Key**: `configPath` - -**Type**: `string` - -**Supported Beautifiers**: [`beautysh`](#beautysh) - -**Description**: - -Path to uncrustify config file. i.e. uncrustify.cfg (Supported by beautysh) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "bash": { - "configPath": "" - } -} -``` - #### [C](#c) **Supported Beautifiers**: [`Uncrustify`](#uncrustify) [`clang-format`](#clang-format) @@ -16971,33 +16946,6 @@ sort imports (requires isort installed) (Supported by autopep8) ``` -### beautysh - -##### [Config Path](#config-path) - -**Namespace**: `bash` - -**Key**: `configPath` - -**Type**: `string` - -**Supported Beautifiers**: [`beautysh`](#beautysh) - -**Description**: - -Path to uncrustify config file. i.e. uncrustify.cfg (Supported by beautysh) - -**Example `.jsbeautifyrc` Configuration** - -```json -{ - "bash": { - "configPath": "" - } -} -``` - - ### coffee-fmt ##### [Indent size](#indent-size) diff --git a/src/beautifiers/beautysh.coffee b/src/beautifiers/beautysh.coffee index 3ed976b..62a22da 100644 --- a/src/beautifiers/beautysh.coffee +++ b/src/beautifiers/beautysh.coffee @@ -5,10 +5,11 @@ module.exports = class BashBeautify extends Beautifier name: "beautysh" link: "https://github.com/bemeurer/beautysh" options: { - Bash: true + Bash: + indent_size: true } beautify: (text, language, options) -> file = @tempFile("input", text) - @run('beautysh', [ file ], help: { link: "https://github.com/bemeurer/beautysh" }) + @run('beautysh', [ '-i', options.indent_size, '-f', file ], help: { link: "https://github.com/bemeurer/beautysh" }) .then(=> @readFile file) diff --git a/src/languages/bash.coffee b/src/languages/bash.coffee index 967be99..f5e7cb7 100644 --- a/src/languages/bash.coffee +++ b/src/languages/bash.coffee @@ -1,3 +1,8 @@ +scope = ['source.sh', 'source.bash'] +tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 2 +softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true +defaultIndentSize = (if softTabs then tabLength else 1) + module.exports = { name: "Bash" @@ -20,4 +25,11 @@ module.exports = { "sh" ] + options: + indent_size: + type: 'integer' + default: defaultIndentSize + minimum: 0 + description: "Indentation size/length" + }