Search code examples
verilogsystem-verilogvscode-extensionssublime-text-pluginautoformatting

Writing a Verilog autoformat extension for Sublime/VS Code


As an RTL developer, I find it annoying that my favorite text editors (Notepad++, Sublime, VS Code) don't have autoformat options for RTL languages like Verilog and VHDL. So I took it upon myself to create one.

I want to develop an auto-format extension for one of those editors. I dropped Notepad++ because it doesn't have native support for Linux and macOS.

So, the question is: how to get started in developing an auto-format extension for a language for Sublime and VS Code?

Notes:

  • I don't intend to develop an extension for both editors but I'd want to see which would be more feasible.

  • With Verilog being closer to C syntax, it might be easier to start there (and I also prefer it over VHDL, but let's not get into religious discussions)

  • I know that Emacs and Sigasi editors provide auto-format options for RTL languages but their format options are strict and I don't like the outcome, hence I intend to make the formatting style configurable

  • I ran into this work https://github.com/thomasrussellmurphy/istyle-verilog-formatter it might be useful to build on it if possible


Solution

  • I don't intend to develop an extension for both editors but I'd want to see which would be more feasible.

    In my opinion, I would prefer coding RTL languages in VS code because it's more versatile than sublime text as in free beer and speech. I would highly recommend beginning from here https://code.visualstudio.com/docs/extensions/example-hello-world. Oh, you also need to know Typescript / Javascript to write an extension.

    I ran into this work https://github.com/thomasrussellmurphy/istyle-verilog-formatter it might be useful to build on it if possible

    I am excited to see the port of this to VS Code/ Sublime Text. I am sorry I don't know how to work on from C++ to TypeScript. My guess would be to copy the implementation method and write in TypeScript.

    From their website :

    Prerequisites:

    You need Node.js installed and available in your $PATH. Node.js includes npm, the Node.js Package Manager, which will be used to install the extension generator.

    I am pretty excited to see auto formatting extensions for Verilog. I hope i can contribute too :)

    Edit : I found this https://github.com/g2384/VHDLFormatter written in TypeScript. The transition to VSCode/Sublime would be easier than the above in C++. I have tested it personally and it works awesome! Hope it helps :)