Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VHDL Support via Emacs #1980

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -13748,6 +13748,125 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
}
```

#### [Vhdl](#vhdl)

**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)

| Option | Vhdl Beautifier |
| --- | --- |
| `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
| `emacs_path` | :white_check_mark: |
| `emacs_script_path` | :white_check_mark: |

**Description**:

Options for language Vhdl

##### [Disable Beautifying Language](#disable-beautifying-language)

**Important**: This option is only configurable from within Atom Beautify's setting panel.

**Type**: `boolean`

**Description**:

Disable Vhdl 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**: `Vhdl Beautifier`

**Type**: `string`

**Enum**: `Vhdl Beautifier`

**Description**:

Default Beautifier to be used for Vhdl

**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 Vhdl 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 path](#emacs-path)

**Namespace**: `vhdl`

**Key**: `emacs_path`

**Type**: `string`

**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)

**Description**:

Path to the `emacs` executable (Supported by Vhdl Beautifier)

**Example `.jsbeautifyrc` Configuration**

```json
{
"vhdl": {
"emacs_path": ""
}
}
```

##### [Emacs script path](#emacs-script-path)

**Namespace**: `vhdl`

**Key**: `emacs_script_path`

**Type**: `string`

**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)

**Description**:

Path to the emacs script (Supported by Vhdl Beautifier)

**Example `.jsbeautifyrc` Configuration**

```json
{
"vhdl": {
"emacs_script_path": ""
}
}
```

#### [Visualforce](#visualforce)

**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
Expand Down Expand Up @@ -19225,6 +19344,57 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
```


### Vhdl Beautifier

##### [Emacs path](#emacs-path)

**Namespace**: `vhdl`

**Key**: `emacs_path`

**Type**: `string`

**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)

**Description**:

Path to the `emacs` executable (Supported by Vhdl Beautifier)

**Example `.jsbeautifyrc` Configuration**

```json
{
"vhdl": {
"emacs_path": ""
}
}
```

##### [Emacs script path](#emacs-script-path)

**Namespace**: `vhdl`

**Key**: `emacs_script_path`

**Type**: `string`

**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)

**Description**:

Path to the emacs script (Supported by Vhdl Beautifier)

**Example `.jsbeautifyrc` Configuration**

```json
{
"vhdl": {
"emacs_script_path": ""
}
}
```


### Vue Beautifier

##### [Indent size](#indent-size)
Expand Down
17 changes: 17 additions & 0 deletions examples/nested-jsbeautifyrc/vhdl/expected/test.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
library ieee;
use ieee.std_logic_1164.all;
entity test is
port(
clk : in std_logic;
d : in std_logic;
q : out std_logic);
end test;
architecture rtl of test is
begin
process (clk)
begin
if rising_edge(clk) then
q <= d;
end if;
end;
end rtl;
17 changes: 17 additions & 0 deletions examples/nested-jsbeautifyrc/vhdl/original/test.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
library ieee;
use ieee.std_logic_1164.all;
entity test is
port(
clk : in std_logic;
d : in std_logic ;
q :out std_logic );
end test;
architecture rtl of test is
begin
process (clk)
begin
if rising_edge(clk) then
q <= d;
end if;
end;
end rtl;
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@
"atom-beautify:beautify-language-xml",
"atom-beautify:beautify-language-xtemplate",
"atom-beautify:beautify-language-yaml",
"atom-beautify:beautify-language-terraform"
"atom-beautify:beautify-language-terraform",
"atom-beautify:beautify-language-vhdl"
],
".tree-view .file .name": [
"atom-beautify:beautify-file"
Expand Down Expand Up @@ -412,7 +413,9 @@
"align-yaml",
"goimports",
"terraform",
"terraformfmt"
"terraformfmt",
"vhdl",
"vhdl beautifier"
],
"devDependencies": {
"coffeelint": "1.16.0"
Expand Down Expand Up @@ -449,4 +452,4 @@
"prettydiff2"
]
}
}
}
1 change: 1 addition & 0 deletions src/beautifiers/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = class Beautifiers extends EventEmitter
'goimports'
'latex-beautify'
'fortran-beautifier'
'vhdl-beautifier'
'js-beautify'
'jscs'
'eslint'
Expand Down
45 changes: 45 additions & 0 deletions src/beautifiers/vhdl-beautifier/emacs-vhdl-formating-script.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
(defun vhdl-batch-indent-region ()
"Run `f90-batch-beatify-region' on the specified filename.
Use this from the command line, with `-batch';
it won't work in an interactive Emacs.
For example, invoke \"emacs -batch -l ~/.emacs-batch-vhdl-indent -f vhdl-batch-indent-region file.f\""
(if (not noninteractive)
(error "`vhdl-batch-indent-region' is to be used only with -batch"))
(let ((make-backup-files nil)
(version-control nil)
(auto-save-default nil)
(find-file-run-dired nil)
(kept-old-versions 259259)
(kept-new-versions 259259))
(let ((error 0)
file
(files ()))
(while command-line-args-left
(setq file (expand-file-name (car command-line-args-left)))
(cond ((not (file-exists-p file))
(message ">> %s does not exist!" file)
(setq error 1
command-line-args-left (cdr command-line-args-left)))
((file-directory-p file)
(setq command-line-args-left
(nconc (directory-files file)
(cdr command-line-args-left))))
(t
(setq files (cons file files)
command-line-args-left (cdr command-line-args-left)))))
(while files
(setq file (car files)
files (cdr files))
(condition-case err
(progn
(if buffer-file-name (kill-buffer (current-buffer)))
(find-file file)
(buffer-disable-undo (current-buffer))
(set-buffer-modified-p nil)
(vhdl-mode)
(message (file-name-nondirectory buffer-file-name))
; compute indentation of first
; line
(vhdl-beautify-buffer)
(save-buffer)
))))))
59 changes: 59 additions & 0 deletions src/beautifiers/vhdl-beautifier/index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
###
Requires https://www.gnu.org/software/emacs/
###

"use strict"
Beautifier = require('../beautifier')
path = require("path")

module.exports = class VhdlBeautifier extends Beautifier
name: "Vhdl Beautifier"
link: "https://www.gnu.org/software/emacs/"
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: {
Vhdl: true
}

beautify: (text, language, options) ->
@debug('vhdl-beautifier', options)
emacs = @exe("emacs")

emacs_path = options.emacs_path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove emacs_path.

emacs_script_path = options.emacs_script_path

if not emacs_script_path
emacs_script_path = path.resolve(__dirname, "emacs-vhdl-formating-script.lisp")

@debug('vhdl-beautifier', 'emacs script path: ' + emacs_script_path)

args = [
'--batch'
'-l'
emacs_script_path
'-f'
'vhdl-batch-indent-region'
tempFile = @tempFile("temp", text)
]

if emacs_path
@deprecateOptionForExecutable("Emacs", "emacs_path", "Path")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This emacs_path option is no longer needed as use of Executables on line 12-20 replaces it.

@run(emacs_path, args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)
else
emacs.run(args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)
1 change: 1 addition & 0 deletions src/languages/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = class Languages
"ux_markup"
"vala"
"vue"
"vhdl"
"visualforce"
"xml"
"xtemplate"
Expand Down
Loading