Format your VHDL code using emacs.
Basically, we call emacs in batch mode, hand in the content of the VHDL file over stdin and retrieve the formatted code over stdout.
The emacs-vhdl-formatter.customEval
option allows you to extend the evaluated
elisp code. This feature allows you to customize the VHDL style before you
format the code. In most cases you want to adjust the vhdl-offsets-alist
which
defines the indentation for various components. Per default this list contains
((string . -1000) -- inside multi-line string
(block-open . 0) -- statement block open
(block-close . 0) -- statement block close
(statement . 0) -- a VHDL statement
(statement-cont . vhdl-lineup-statement-cont) -- a continuation of a VHDL statement
(statement-block-intro . +) -- the first line in a new statement block
(statement-case-intro . +) -- the first line in a case alternative block
(case-alternative . +) -- a case statement alternative clause
(comment . vhdl-lineup-comment) -- a line containing only a comment
(arglist-intro . +) -- the first line in an argument list
(arglist-cont . 0) -- subsequent argument list lines when no
arguments follow on the same line as
the arglist opening paren
(arglist-cont-nonempty . vhdl-lineup-arglist) -- subsequent argument list lines when at
least one argument follows on the same
line as the arglist opening paren
(arglist-close . vhdl-lineup-arglist) -- the solo close paren of an argument list
(entity . 0) -- inside an entity declaration
(configuration . 0) -- inside a configuration declaration
(package . 0) -- inside a package declaration
(architecture . 0) -- inside an architecture body
(package-body . 0) -- inside a package body
(context . 0)) -- inside a context declaration
Use vhdl-set-offset
function to change values in vhdl-offsets-alist
. For
example to remove the indentation on closing brackets set
emacs-vhdl-formatter.customEval
to
(vhdl-set-offset 'arglist-close 0)
This plugin requires you to have Emacs installed and available in your path.
We recommend Windows users to install emacs in a wsl and then call emacs within that wsl. Currently, this is the default configuration for Windows users. However, if you manage to do it otherwise, feel free to do so.
This extension contributes the following settings:
emacs-vhdl-formatter.executable.unix
: Emacs executable on Unix based systems. Defaults toemacs
.emacs-vhdl-formatter.executable.windows
: Emacs executable on Windows. Defaults towsl
to run emacs inside the wsl.emacs-vhdl-formatter.extraArgs.windows
: Additional arguments on Windows separated by spaces. Defaults toemacs
as an argument to wsl.emacs-vhdl-formatter.customEval
: Custom elisp code which gets executed before the document is formatted. Defaults to(vhdl-set-style \"IEEE\")
.
See CHANGELOG for details.