diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85f7041..7a80a95 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/README.md b/README.md
index be11077..56a9d4b 100644
--- a/README.md
+++ b/README.md
@@ -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:
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
|
@@ -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) |
diff --git a/docs/options.md b/docs/options.md
index 2acbe41..31315c7 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -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)
diff --git a/examples/nested-jsbeautifyrc/verilog/expected/test.v b/examples/nested-jsbeautifyrc/verilog/expected/test.v
new file mode 100644
index 0000000..5e2198c
--- /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 8d2321f..a16f1c8 100644
--- a/package.json
+++ b/package.json
@@ -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"
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 54117a1..84c58ed 100644
--- a/src/beautifiers/index.coffee
+++ b/src/beautifiers/index.coffee
@@ -84,6 +84,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..968338c
--- /dev/null
+++ b/src/beautifiers/verilog-mode/verilog-mode.el
@@ -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))
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 57e34c6..1a01b1a 100644
--- a/src/options.json
+++ b/src/options.json
@@ -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",