diff --git a/CHANGELOG.md b/CHANGELOG.md
index e51a050..1ce555c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# Next
- Fix [#1862](https://github.com/Glavin001/atom-beautify/issues/1862) Add support for ocp-indent as an executable
- See [#601](https://github.com/Glavin001/atom-beautify/issues/1862) Add support for tsx files
+- Implement Verilog/SystemVerilog beautification via emacs verilog-mode
# v0.30.9 (2017-11-22)
- Fix [#1949](https://github.com/Glavin001/atom-beautify/issues/1949): Fix beautify on save when text has not changed.
diff --git a/README.md b/README.md
index 7720f42..27d9e57 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,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:
1. Install [Dfmt (`dfmt`)](https://github.com/Hackerpilot/dfmt) by following https://github.com/dlang-community/dfmt#building
|
| elm-format | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [elm-format (`elm-format`)](https://github.com/avh4/elm-format) with `docker pull unibeautify/elm-format`
:bookmark_tabs: Manually:
1. Install [elm-format (`elm-format`)](https://github.com/avh4/elm-format) by following https://github.com/avh4/elm-format#installation-
|
+| Emacs Verilog Mode | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:
1. Install [Emacs (`emacs`)](https://www.gnu.org/software/emacs/) by following https://www.gnu.org/software/emacs/
|
| 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/):
1. Install [Rscript (`rscript`)](https://github.com/yihui/formatR) with `docker pull unibeautify/rscript`
:bookmark_tabs: Manually:
1. Install [Rscript (`rscript`)](https://github.com/yihui/formatR) by following https://github.com/yihui/formatR
|
@@ -204,6 +205,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)** |
| 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)** |
| 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) |
diff --git a/docs/options.md b/docs/options.md
index 6047ede..0bdb8f8 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -13851,6 +13851,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)
@@ -16183,6 +16277,33 @@ Override EOL from line-ending-selector (Supported by Coffee Formatter)
```
+### 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)
diff --git a/examples/nested-jsbeautifyrc/verilog/expected/test.v b/examples/nested-jsbeautifyrc/verilog/expected/test.v
new file mode 100644
index 0000000..6dd5d4d
--- /dev/null
+++ b/examples/nested-jsbeautifyrc/verilog/expected/test.v
@@ -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
diff --git a/examples/nested-jsbeautifyrc/verilog/original/test.v b/examples/nested-jsbeautifyrc/verilog/original/test.v
new file mode 100644
index 0000000..bc94897
--- /dev/null
+++ b/examples/nested-jsbeautifyrc/verilog/original/test.v
@@ -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
diff --git a/package.json b/package.json
index bdb74b1..7931382 100644
--- a/package.json
+++ b/package.json
@@ -150,6 +150,10 @@
{
"name": "Steven Zeck",
"url": "https://github.com/szeck87"
+ },
+ {
+ "name": "Andrew Andrianov",
+ "url": "https://github.com/nekromant"
}
],
"engines": {
@@ -278,7 +282,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"
@@ -414,7 +419,9 @@
"goimports",
"terraform",
"terraformfmt",
- "tsx"
+ "tsx",
+ "verilog",
+ "emacs verilog mode"
],
"devDependencies": {
"coffeelint": "1.16.0"
@@ -451,4 +458,4 @@
"prettydiff2"
]
}
-}
\ No newline at end of file
+}
diff --git a/src/beautifiers/executable.coffee b/src/beautifiers/executable.coffee
index d2f876b..99c7c01 100644
--- a/src/beautifiers/executable.coffee
+++ b/src/beautifiers/executable.coffee
@@ -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()
diff --git a/src/beautifiers/fortran-beautifier/index.coffee b/src/beautifiers/fortran-beautifier/index.coffee
index f437da8..2d8125b 100644
--- a/src/beautifiers/fortran-beautifier/index.coffee
+++ b/src/beautifiers/fortran-beautifier/index.coffee
@@ -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'
diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee
index cc3f237..37e6924 100644
--- a/src/beautifiers/index.coffee
+++ b/src/beautifiers/index.coffee
@@ -81,6 +81,7 @@ module.exports = class Beautifiers extends EventEmitter
'formatR'
'beautysh'
'terraformfmt'
+ 'verilog-mode'
]
###
diff --git a/src/beautifiers/verilog-mode/index.coffee b/src/beautifiers/verilog-mode/index.coffee
new file mode 100644
index 0000000..153b4d7
--- /dev/null
+++ b/src/beautifiers/verilog-mode/index.coffee
@@ -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)
+ )
diff --git a/src/beautifiers/verilog-mode/verilog-mode.el b/src/beautifiers/verilog-mode/verilog-mode.el
new file mode 100644
index 0000000..74132cb
--- /dev/null
+++ b/src/beautifiers/verilog-mode/verilog-mode.el
@@ -0,0 +1,3 @@
+(add-hook 'verilog-mode-hook '(lambda ()
+ (add-hook 'local-write-file-hooks (lambda()
+ (untabify (point-min) (point-max))))))
diff --git a/src/languages/index.coffee b/src/languages/index.coffee
index 69c14a8..80286ae 100644
--- a/src/languages/index.coffee
+++ b/src/languages/index.coffee
@@ -79,6 +79,7 @@ module.exports = class Languages
"xtemplate"
"yaml"
"terraform"
+ "verilog"
]
###
diff --git a/src/languages/verilog.coffee b/src/languages/verilog.coffee
new file mode 100644
index 0000000..d7b6a68
--- /dev/null
+++ b/src/languages/verilog.coffee
@@ -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)"
+
+}
diff --git a/src/options.json b/src/options.json
index d545bd3..6bd9252 100644
--- a/src/options.json
+++ b/src/options.json
@@ -9210,6 +9210,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",