Emacs on-the-fly (as you type) syntax checking for VHDL [flycheck, nvc]

Flycheck is an on the fly syntax checker for Emacs. When configured properly it performs really great. Flycheck itself doesn’t do syntax checking. It uses external tools for that. There are many syntax checker tools out there for programming languages like C and python, but none for vhdl. Then I’ve noticed that error output of nvc vhdl simulator is quite helpful and decided to use it as syntax checker back end. Result was better then I expected.

Integrating nvc with flycheck wasn’t hard. It’s merely adding a few lines to your init file. See below. I think the code is self-explanatory.

(flycheck-define-checker vhdl-nvc
 "A VHDL syntax checker using nvc."
 :command ("nvc" "--message=compact" "-a" source)
 ((error line-start (file-name) ":" line ":" column
 ": error: " (message) line-end))
 :modes vhdl-mode)

Obviously you will need nvc vhdl simulator for this to work. Get it from here: https://github.com/nickg/nvc

It’s not the best and you may encounter some problems using nvc like that, after all it’s not designed for this purpose. But it’s still pretty useful.

Leave a Reply

Your email address will not be published.