Merge branch 'samogot-gn'

This commit is contained in:
Glavin Wiechert 2018-03-01 21:54:51 -04:00
commit 40374599ce
11 changed files with 247 additions and 2 deletions

View File

@ -1,4 +1,5 @@
# Next
- Add GN language and beautifier
- Add the option to indent Bash with tabs [#1951](https://github.com/Glavin001/atom-beautify/issues/1951)
- See [#1980](https://github.com/Glavin001/atom-beautify/pull/1980). Add VHDL beautifier and language support.
- Implement Verilog/SystemVerilog beautification via emacs verilog-mode

View File

@ -106,6 +106,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall
| formatR | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [Rscript (`rscript`)](https://github.com/yihui/formatR) with `docker pull unibeautify/rscript`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [Rscript (`rscript`)](https://github.com/yihui/formatR) by following https://github.com/yihui/formatR<br/> |
| Fortran Beautifier | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:<br/>1. Install [Emacs (`emacs`)](https://www.gnu.org/software/emacs/) by following https://www.gnu.org/software/emacs/<br/> |
| Gherkin formatter | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| GN | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:<br/>1. Install [gn (`gn`)](https://chromium.googlesource.com/chromium/src/tools/gn) by following https://www.chromium.org/developers/how-tos/get-the-code<br/> |
| gofmt | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://golang.org/cmd/gofmt/ and follow the instructions. |
| goimports | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [goimports (`goimports`)](https://godoc.org/golang.org/x/tools/cmd/goimports) with `docker pull unibeautify/goimports`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [goimports (`goimports`)](https://godoc.org/golang.org/x/tools/cmd/goimports) by following https://godoc.org/golang.org/x/tools/cmd/goimports<br/> |
| hh_format | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to http://hhvm.com/ and follow the instructions. |
@ -167,6 +168,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| Fortran | `Fortran - Modern` |`.f90`, `.F90`, `.f95`, `.F95`, `.f03`, `.F03`, `.f08`, `.F08` | **[`Fortran Beautifier`](https://www.gnu.org/software/emacs/)** |
| gherkin | `Gherkin` |`.feature` | **[`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee)** |
| GLSL | `C`, `opencl`, `GLSL` |`.vert`, `.frag` | **[`clang-format`](https://clang.llvm.org/docs/ClangFormat.html)** |
| GN | `gn` |`.gn`, `.gni` | **[`GN`](https://chromium.googlesource.com/chromium/src/tools/gn)** |
| Go | `Go` |`.go` | **[`gofmt`](https://golang.org/cmd/gofmt/)**, [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports) |
| Golang Template | `HTML (Go)`, `Go Template` |`.gohtml` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Handlebars | `Handlebars`, `HTML (Handlebars)` |`.hbs`, `.handlebars` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |

View File

@ -249,6 +249,23 @@ Options for Emacs executable.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Emacs*" and change it to your desired configuration.
##### [gn](#gn)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `object`
**Description**:
Options for gn executable.
**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 "*gn*" and change it to your desired configuration.
##### [goimports](#goimports)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
@ -3597,6 +3614,75 @@ Path to clang-format config file. i.e. clang-format.cfg (Supported by clang-form
}
```
#### [GN](#gn)
**Supported Beautifiers**: [`GN`](#gn)
| Option | GN |
| --- | --- |
| `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
**Description**:
Options for language GN
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable GN 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**: `GN`
**Type**: `string`
**Enum**: `GN`
**Description**:
Default Beautifier to be used for GN
**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 GN 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.
#### [Go](#go)
**Supported Beautifiers**: [`gofmt`](#gofmt) [`goimports`](#goimports)

View File

@ -0,0 +1,19 @@
shared_library("test") {
# NOSORT
sources = [
"z.cc",
"a.cc",
]
deps = [
"//abc:deps",
]
include_dirs = [ "." ]
if (is_win) {
sources += [
"a.cpp",
"b.cpp",
]
}
}

View File

@ -0,0 +1,18 @@
shared_library("test") {
# NOSORT
sources = [
"z.cc",
"a.cc",
]
deps=["//abc:deps"]
include_dirs = [
".",
]
if (is_win) {
sources += ["b.cpp","a.cpp"]
}
}

View File

@ -294,7 +294,8 @@
"atom-beautify:beautify-language-terraform",
"atom-beautify:beautify-language-tsx",
"atom-beautify:beautify-language-verilog",
"atom-beautify:beautify-language-vhdl"
"atom-beautify:beautify-language-vhdl",
"atom-beautify:beautify-language-gn"
],
".tree-view .file .name": [
"atom-beautify:beautify-file"
@ -437,7 +438,8 @@
"verilog",
"emacs verilog mode",
"vhdl",
"vhdl beautifier"
"vhdl beautifier",
"gn"
],
"devDependencies": {
"coffeelint": "1.16.0"

34
src/beautifiers/gn.coffee Normal file
View File

@ -0,0 +1,34 @@
###
Requires [gn](https://chromium.googlesource.com/chromium/src/tools/gn)
###
"use strict"
Beautifier = require('./beautifier')
path = require('path')
semver = require('semver')
module.exports = class GN extends Beautifier
name: "GN"
link: "https://chromium.googlesource.com/chromium/src/tools/gn"
executables: [
{
name: "gn"
cmd: "gn"
homepage: "https://chromium.googlesource.com/chromium/src/tools/gn"
installation: "https://www.chromium.org/developers/how-tos/get-the-code"
version: {
parse: (text) -> semver.clean("0.0." + text)
}
}
]
options: {
GN: false
}
beautify: (text, language, options, context) ->
cwd = context.filePath and path.dirname context.filePath
@exe("gn").run(["format", "--stdin"], {
cwd: cwd
onStdin: (stdin) ->
stdin.end text
})

View File

@ -49,6 +49,7 @@ module.exports = class Beautifiers extends EventEmitter
'htmlbeautifier'
'csscomb'
'gherkin'
'gn'
'gofmt'
'goimports'
'latex-beautify'

23
src/languages/gn.coffee Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
name: "GN"
namespace: "gn"
###
Supported Grammars
###
grammars: [
"gn"
]
###
Supported extensions
###
extensions: [
"gn"
"gni"
]
defaultBeautifier: "GN"
}

View File

@ -31,6 +31,7 @@ module.exports = class Languages
"erlang"
"gherkin"
"glsl"
"gn"
"go"
"gohtml"
"fortran"

View File

@ -1856,6 +1856,48 @@
}
}
},
"gn": {
"title": "GN",
"type": "object",
"description": "Options for language GN",
"collapsed": true,
"beautifiers": [
"GN"
],
"grammars": [
"gn"
],
"extensions": [
"gn",
"gni"
],
"properties": {
"disabled": {
"title": "Disable Beautifying Language",
"order": -3,
"type": "boolean",
"default": false,
"description": "Disable GN Beautification"
},
"default_beautifier": {
"title": "Default Beautifier",
"order": -2,
"type": "string",
"default": "GN",
"description": "Default Beautifier to be used for GN",
"enum": [
"GN"
]
},
"beautify_on_save": {
"title": "Beautify On Save",
"order": -1,
"type": "boolean",
"default": false,
"description": "Automatically beautify GN files on save"
}
}
},
"go": {
"title": "Go",
"type": "object",
@ -9077,6 +9119,22 @@
}
}
},
"gn": {
"key": "gn",
"title": "gn",
"type": "object",
"collapsed": true,
"description": "Options for gn executable.",
"properties": {
"path": {
"key": "path",
"title": "Binary/Script Path",
"type": "string",
"default": "",
"description": "Absolute path to the \"gn\" executable's binary/script."
}
}
},
"goimports": {
"key": "goimports",
"title": "goimports",