Merge pull request #1466 from s4l1h/master

Golang template support.
This commit is contained in:
Glavin Wiechert 2017-04-15 01:47:58 -03:00 committed by GitHub
commit bc58ae9fe6
6 changed files with 211 additions and 1 deletions

View File

@ -131,6 +131,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) |
| GLSL | `C`, `opencl`, `GLSL` |`.vert`, `.frag` | [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (Default) |
| Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) |
| Golang Template | `HTML (Go)`, `Go Template` |`.gohtml` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Handlebars | `Handlebars`, `HTML (Handlebars)` |`.hbs`, `.handlebars` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
| Haskell | `Haskell` |`.hs` | [`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell) (Default) |
| HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |

View File

@ -3685,6 +3685,183 @@ Automatically beautify Go 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.
#### [Golang Template](#golang-template)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
| Option | Pretty Diff |
| --- | --- |
| `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
| `indent_char` | :white_check_mark: |
| `indent_size` | :white_check_mark: |
| `preserve_newlines` | :white_check_mark: |
| `wrap_line_length` | :white_check_mark: |
**Description**:
Options for language Golang Template
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable Golang Template 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**: `Pretty Diff`
**Type**: `string`
**Enum**: `Pretty Diff`
**Description**:
Default Beautifier to be used for Golang Template
**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 Golang Template 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.
##### [Indent char](#indent-char)
**Namespace**: `html`
**Key**: `indent_char`
**Default**: ` `
**Type**: `string`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Indentation character (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"html": {
"indent_char": " "
}
}
```
##### [Indent size](#indent-size)
**Namespace**: `html`
**Key**: `indent_size`
**Default**: `4`
**Type**: `integer`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Indentation size/length (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"html": {
"indent_size": 4
}
}
```
##### [Preserve newlines](#preserve-newlines)
**Namespace**: `html`
**Key**: `preserve_newlines`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Preserve line-breaks (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"html": {
"preserve_newlines": true
}
}
```
##### [Wrap line length](#wrap-line-length)
**Namespace**: `html`
**Key**: `wrap_line_length`
**Default**: `250`
**Type**: `integer`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Maximum characters per line (0 disables) (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"html": {
"wrap_line_length": 250
}
}
```
#### [Handlebars](#handlebars)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)

View File

@ -306,7 +306,8 @@
"bash",
"beautysh",
"glsl",
"hh_format"
"hh_format",
"golang template"
],
"devDependencies": {
"coffeelint": "^1.10.1",

View File

@ -67,6 +67,7 @@ module.exports = class PrettyDiff extends Beautifier
Visualforce: true
"Riot.js": true
XTemplate: true
"Golang Template": true
}
beautify: (text, language, options) ->
@ -110,6 +111,8 @@ module.exports = class PrettyDiff extends Beautifier
lang = "scss"
when "TSS"
lang = "tss"
when "Golang Template"
lang = "go"
else
lang = "auto"

View File

@ -0,0 +1,27 @@
module.exports = {
name: "Golang Template"
description: "Comma-Separated Values"
namespace: "gohtml"
fallback: ["html"]
###
Supported Grammars
###
grammars: [
"HTML (Go)",
"Go Template"
]
###
Supported extensions
###
extensions: [
'gohtml'
]
defaultBeautifier: "Pretty Diff"
options: []
}

View File

@ -32,6 +32,7 @@ module.exports = class Languages
"gherkin"
"glsl"
"go"
"gohtml"
"fortran"
"handlebars"
"haskell"