Sublime Text and Snippets Config for OpenJscad
Today, i want to talk about OpenJscad. It’s like OpenScad, but on javascript basis. You can code rigth in your browser (with WebGL support) or in your favorite text editor, but model render anyway take place in web browser.
You can check my previous article about OpenSCAD to understand the work process in some programs simultaneously.
Coding online is not very convenient for me, although there is a built-in debugger there, highlighting the line with errors and so on, but my model always opened on the second monitor, so i usually look to debugger only after render fails.
As there is no offline editor\compiler specially for openjscad, Sublime Text will help us again. Let’s config it.
In Sublime switch code highlight to javascript. In order to have js autocomplete download SublimeCodeIntel, and for scad complete just use snippets.
Create snippets in XML is rather hard, so download and install sane packet — sublime-sane-snippets.
Here goes simple example of creating and using snippets:
From menu: Tools — Packages — SaneSnippets — New SaneSnippet…
Use guide for openjscad and make something like this:
where:
- discription - simple discription will show in autocomplete window
- tabTrigger - word, trigger for hint to occur
- scope - scope of work, just type sourse.js for friendly usage with javascript
Next goes the actual snippet code.
$n
- places for tab jumps, note$0
will be the last place to go, no matter where it is. Code:${1: text1|text2|text3}
- shows text1|text2|text3 as hint or default value;
That’s all. Save your snippet with propper name and .sane-snippet extension. Then .sublime-snippet will be generated automatically. In the neighbour tab you can check your work immidiatly, without restarting the programm.
Good luck!