Merge branch 'master' of https://github.com/nekromant/atom-beautify into nekromant-master

This commit is contained in:
Glavin Wiechert 2018-03-01 20:49:41 -04:00
commit abbc8b3bf1
14 changed files with 367 additions and 4 deletions

View File

@ -1,4 +1,5 @@
# Next
- Implement Verilog/SystemVerilog beautification via emacs verilog-mode
- Add support for MagicPython grammar [#1851](https://github.com/Glavin001/atom-beautify/issues/1851)
- Add "Reindent" option for sqlformat. See [#1926](https://github.com/Glavin001/atom-beautify/pull/1926).
- Add hindent and brittany beautifiers for haskell

View File

@ -100,6 +100,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall
| CSScomb | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| dfmt | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:<br/>1. Install [Dfmt (`dfmt`)](https://github.com/Hackerpilot/dfmt) by following https://github.com/dlang-community/dfmt#building<br/> |
| elm-format | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [elm-format (`elm-format`)](https://github.com/avh4/elm-format) with `docker pull unibeautify/elm-format`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [elm-format (`elm-format`)](https://github.com/avh4/elm-format) by following https://github.com/avh4/elm-format#installation-<br/> |
| Emacs Verilog Mode | :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/> |
| erl_tidy | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to http://erlang.org/doc/man/erl_tidy.html and follow the instructions. |
| ESLint Fixer | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| 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/> |
@ -207,6 +208,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| TypeScript | `TypeScript` |`.ts` | **[`TypeScript Formatter`](https://github.com/vvakame/typescript-formatter)**, [`Prettier`](https://github.com/prettier/prettier) |
| UX Markup | `UX` |`.ux` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Vala | `Vala` |`.vala`, `.vapi` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** |
| Verilog | `Verilog` |`.svh`, `.v`, `.sv` | **[`Emacs Verilog Mode`](https://www.veripool.org/projects/verilog-mode/)** |
| Visualforce | `Visualforce` |`.page` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Vue | `Vue Component` |`.vue` | **[`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee)**, [`Prettier`](https://github.com/prettier/prettier) |
| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe`, `.config` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`JS Beautify`](https://github.com/beautify-web/js-beautify) |

View File

@ -13125,6 +13125,100 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
}
```
#### [Verilog](#verilog)
**Supported Beautifiers**: [`Emacs Verilog Mode`](#emacs-verilog-mode)
| Option | Emacs Verilog Mode |
| --- | --- |
| `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
| `emacs_script_path` | :white_check_mark: |
**Description**:
Options for language Verilog
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable Verilog 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**: `Emacs Verilog Mode`
**Type**: `string`
**Enum**: `Emacs Verilog Mode`
**Description**:
Default Beautifier to be used for Verilog
**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 Verilog 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.
##### [Emacs script path](#emacs-script-path)
**Namespace**: `verilog`
**Key**: `emacs_script_path`
**Type**: `string`
**Supported Beautifiers**: [`Emacs Verilog Mode`](#emacs-verilog-mode)
**Description**:
Path to emacs init.el script with formatting settings. (Leave blank to use default one) (Supported by Emacs Verilog Mode)
**Example `.jsbeautifyrc` Configuration**
```json
{
"verilog": {
"emacs_script_path": ""
}
}
```
#### [Visualforce](#visualforce)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
@ -14981,6 +15075,33 @@ Used if neither a project or custom config file exists. (Supported by CSScomb)
```
### Emacs Verilog Mode
##### [Emacs script path](#emacs-script-path)
**Namespace**: `verilog`
**Key**: `emacs_script_path`
**Type**: `string`
**Supported Beautifiers**: [`Emacs Verilog Mode`](#emacs-verilog-mode)
**Description**:
Path to emacs init.el script with formatting settings. (Leave blank to use default one) (Supported by Emacs Verilog Mode)
**Example `.jsbeautifyrc` Configuration**
```json
{
"verilog": {
"emacs_script_path": ""
}
}
```
### Fortran Beautifier
##### [Emacs path](#emacs-path)

View File

@ -0,0 +1,33 @@
// Testbench
module test;
reg clk;
reg reset;
reg d;
wire q;
wire qb;
// Instantiate design under test
dff DFF(.clk(clk), .reset(reset),
.d(d), .q(q), .qb(qb));
initial begin
// Dump waves
$dumpfile("dump.vcd");
$dumpvars(1);
$display("Reset flop.");
clk = 0;
reset = 1;
d = 1'bx;
display;
$display("Release reset.");
d = 1;
reset = 0;
display;
$display("Toggle clk.");
clk = 1;
display;
end
task display;
#1 $display("d:%0h, q:%0h, qb:%0h",
d, q, qb);
endtask
endmodule

View File

@ -0,0 +1,33 @@
// Testbench
module test;
reg clk;
reg reset;
reg d;
wire q;
wire qb;
// Instantiate design under test
dff DFF(.clk(clk), .reset(reset),
.d(d), .q(q), .qb(qb));
initial begin
// Dump waves
$dumpfile("dump.vcd");
$dumpvars(1);
$display("Reset flop.");
clk = 0;
reset = 1;
d = 1'bx;
display;
$display("Release reset.");
d = 1;
reset = 0;
display;
$display("Toggle clk.");
clk = 1;
display;
end
task display;
#1 $display("d:%0h, q:%0h, qb:%0h",
d, q, qb);
endtask
endmodule

View File

@ -159,6 +159,10 @@
{
"name": "Faheel Ahmad",
"url": "https://github.com/faheel"
},
{
"name": "Andrew Andrianov",
"url": "https://github.com/nekromant"
}
],
"engines": {
@ -288,7 +292,8 @@
"atom-beautify:beautify-language-xtemplate",
"atom-beautify:beautify-language-yaml",
"atom-beautify:beautify-language-terraform",
"atom-beautify:beautify-language-tsx"
"atom-beautify:beautify-language-tsx",
"atom-beautify:beautify-language-verilog"
],
".tree-view .file .name": [
"atom-beautify:beautify-file"
@ -427,7 +432,9 @@
"terraform",
"terraformfmt",
"tsx",
"prettier"
"prettier",
"verilog",
"emacs verilog mode"
],
"devDependencies": {
"coffeelint": "1.16.0"

View File

@ -130,7 +130,7 @@ class Executable
Run command-line interface command
###
run: (args, options = {}) ->
@debug("Run: ", @cmd, args, options)
console.log("Run: ", @cmd, args, options)
{ cmd, cwd, ignoreReturnCode, help, onStdin, returnStderr, returnStdoutOrStderr } = options
exeName = cmd or @cmd
cwd ?= os.tmpdir()

View File

@ -36,7 +36,7 @@ module.exports = class FortranBeautifier extends Beautifier
emacs_script_path = path.resolve(__dirname, "emacs-fortran-formating-script.lisp")
@debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)
args = [
'--batch'
'-l'

View File

@ -84,6 +84,7 @@ module.exports = class Beautifiers extends EventEmitter
'formatR'
'beautysh'
'terraformfmt'
'verilog-mode'
]
###

View File

@ -0,0 +1,57 @@
###
Requires emacs with verilog-mode https://www.veripool.org/wiki/verilog-mode
###
"use strict"
Beautifier = require('../beautifier')
path = require("path")
module.exports = class EmacsVerilogMode extends Beautifier
name: "Emacs Verilog Mode"
link: "https://www.veripool.org/projects/verilog-mode/"
isPreInstalled: false
executables: [
{
name: "Emacs"
cmd: "emacs"
homepage: "https://www.gnu.org/software/emacs/"
installation: "https://www.gnu.org/software/emacs/"
version: {
parse: (text) -> text.match(/Emacs (\d+\.\d+\.\d+)/)[1]
}
}
]
options: {
Verilog: {
emacs_script_path: true
}
}
beautify: (text, language, options) ->
emacs_script_path = options.emacs_script_path
if not emacs_script_path
emacs_script_path = path.resolve(__dirname, "verilog-mode.el")
@debug('verilog-beautifier', 'emacs script path: ' + emacs_script_path)
tempFile = @tempFile("input", text)
args = [
"--batch"
tempFile
"-l"
emacs_script_path
"-f"
"verilog-mode"
"-f"
"verilog-batch-indent"
]
@debug('verilog-beautifier', 'emacs args: ' + args)
@exe("emacs").run(args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)

View File

@ -0,0 +1,22 @@
(add-hook 'verilog-mode-hook '(lambda ()
(add-hook 'local-write-file-hooks (lambda()
(untabify (point-min) (point-max))))))
(custom-set-variables
'(verilog-align-ifelse t)
'(verilog-auto-delete-trailing-whitespace t)
'(verilog-auto-inst-param-value t)
'(verilog-auto-inst-vector nil)
'(verilog-auto-lineup (quote all))
'(verilog-auto-newline nil)
'(verilog-auto-save-policy nil)
'(verilog-auto-template-warn-unused t)
'(verilog-case-indent 2)
'(verilog-cexp-indent 2)
'(verilog-highlight-grouping-keywords t)
'(verilog-highlight-modules t)
'(verilog-indent-level 2)
'(verilog-indent-level-behavioral 2)
'(verilog-indent-level-declaration 2)
'(verilog-indent-level-module 2)
'(verilog-tab-to-comment t))

View File

@ -79,6 +79,7 @@ module.exports = class Languages
"xtemplate"
"yaml"
"terraform"
"verilog"
]
###

View File

@ -0,0 +1,28 @@
module.exports = {
name: "Verilog"
namespace: "verilog"
###
Supported Grammars
###
grammars: [
"Verilog"
]
###
Supported extensions
###
extensions: [
"svh"
"v"
"sv"
]
options:
emacs_script_path:
type: 'string'
default: ""
description: "Path to emacs init.el script with formatting settings. (Leave blank to use default one)"
}

View File

@ -8831,6 +8831,63 @@
}
}
},
"verilog": {
"title": "Verilog",
"type": "object",
"description": "Options for language Verilog",
"collapsed": true,
"beautifiers": [
"Emacs Verilog Mode"
],
"grammars": [
"Verilog"
],
"extensions": [
"svh",
"v",
"sv"
],
"properties": {
"emacs_script_path": {
"type": "string",
"default": "",
"description": "Path to emacs init.el script with formatting settings. (Leave blank to use default one) (Supported by Emacs Verilog Mode)",
"title": "Emacs script path",
"beautifiers": [
"Emacs Verilog Mode"
],
"key": "emacs_script_path",
"language": {
"name": "Verilog",
"namespace": "verilog"
}
},
"disabled": {
"title": "Disable Beautifying Language",
"order": -3,
"type": "boolean",
"default": false,
"description": "Disable Verilog Beautification"
},
"default_beautifier": {
"title": "Default Beautifier",
"order": -2,
"type": "string",
"default": "Emacs Verilog Mode",
"description": "Default Beautifier to be used for Verilog",
"enum": [
"Emacs Verilog Mode"
]
},
"beautify_on_save": {
"title": "Beautify On Save",
"order": -1,
"type": "boolean",
"default": false,
"description": "Automatically beautify Verilog files on save"
}
}
},
"executables": {
"title": "Executables",
"type": "object",