VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=Antyos.openscad
GitHub Link: https://github.com/Antyos/vscode-openscad
One of my favorite Computer Aided Design (CAD) programs is called OpenSCAD. Unlike most CAD programs, it generates its models entirely with code. While the learning curve is steep and it’s not something I use for every project, it has its place in my toolkit and can be fun to use.
With that being said, the default editor for OpenSCAD is not that great. I switched to Visual Studio Code as my main code editor quite some time ago and enjoy using all of the advanced features like Intellisense. So logically, I tried to see if I could edit OpenSCAD files using VS Code.
It turns out it is rather simple to use an external editor with OpenSCAD. However, the only syntax highlighting plugin available for .scad files (by Erik Benson) was not to my liking. It didn’t highlight everything it should, and what it did highlight were the wrong colors. I did some research and found someone (GitHub user atnbueno) made a fix for this, but it still was not ideal. The main feature I wanted was highlighting for user-generated functions/methods and to highlight the arguments in those functions, similar to Python highlighting.
Building off of atnbueno’s work, I created my own extension to do what I wanted. I learned how the highlighting algorithm works in VS Code which uses the TextMate syntax for creating custom grammars (what to highlight). That led me to learn how to use Regular Expressions and yaml, as well as some other general stuff tailored to VS Code extensions.
Five(ish) months later, I have my first extension published! There are still a number of features I want to add, such as the ability to launch OpenSCAD through VS Code to preview the file you are currently working on. For now though, I thought it would be best to get the extension out there.
VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=Antyos.openscad
GitHub Link: https://github.com/Antyos/vscode-openscad