SenX recommended VSCode setup to improve your WarpScript skills in 2020. Discover the latest features of WarpScript VSCode extension.
We constantly improve this extension for power users, but we rarely communicate on changes. Here is a review of the current features, and our "pro tips" to configure VSCode for WarpScript.
WarpScript In, Json Out
If you expect a human readable result from your WarpScript, configure your keyboard to format Json easily: on my personal keyboard layout (french bépo), I choose ctrl+alt+E to run WarpScript, and ctrl+alt+I to format Json. The keys
I are very close on this keyboard layout.
As soon as you format the json output, VSCode will keep it opened. If you run 100 times the same script, you will have 100 json on the right pane... You can set a shortcut to clean your workspace from all the json opened results. As VSCode does not provide a way to list the opened tabs, this experimental feature closes all unsaved Warp 10 json output.
In the shortcut menu, you can also change
toggle line comment shortcut to select something you are used to.
Your personal keyboard preferences will be stored in
VSCode will try to detect indentation. Bad idea. In the settings (
ctrl+,) force indentation to the number of spaces you want.
If your computer is fast, the default completion timings could let you to type something you do not want. Rising the completion timer to 200ms or more is a good idea:
Last but not least, make WarpScript your default language! It will avoid you to painfully select the language on every new "untitled" file you create:
Bracket pair colorizer from CoenraadS is helpful. Choose version 2: version 1, the most popular, does not use VScode bracket parsing engine, and won't work out of the box with WarpScript. In VScode, press Ctrl+P, then type
ext install coenraads.bracket-pair-colorizer-2 .
Problem: this extension will also try to beautify the 20MB json you will sometimes retrieve from Warp 10... Here is the trick to exclude json from bracket colorizer:
Features you already master... or not!
Online help, even for remote macros
If you use WarpFleet, or some remote repos to share macros, or simply macros in your Warp 10 server "macros" directory, WarpScript extension will try to execute the macro in INFOMODE on the server, to retrieve the help from the macro.
This feature takes into account the endpoint and the WF.ADDREPO functions within the current WarpScript.
Macro highlights and code lens
Click on a control instruction to highlight the input macros content. For example, click on IFT will highlight the "if" macro and the "then" macro (in a different color).
If a macro is too long in a control structure (more than 20 lines), a code lens appears at the beginning of the macro to help you to read the code: click on this code lens will focus on the control instruction that will consume the macro.
Both features are here to help you to read long WarpScripts files. You can disable this behavior in the extension settings.
If you develop a big project, you will need to split and refactor your WarpScript into WarpScript macros. Once the macros are available on your server "macro" directory, you can call them. Pushing the macros on your server is straightforward if you are the server admin. If you're not, it means you will have to ask the sysadmin to update macros each time you fix a bug in your macro. You can of course use WarpFleet or external static repos. But the fastest way to debug macros in a big project is to use VSCode macro substitution.
This feature is activated by default in VSCode WarpScript extension. The extension will look into the project directory and sub-directories if there is the same file path: if a local file is found, the macro became a hyperlink to the local file. Each time you execute your WarpScript, the macros found as local files are automagically appended to the WarpScript. Just try with a simple example:
Special comments on VSCode
At the beginning of your WarpScript, you can write several special comments that will be parsed by VSCode extension:
The extension will parse the first comment block to look for
// @xx comments.
endpointallow you to play with several endpoints in the same project, without changing your global extension preferences.
localmacrosubstitutioncan disable the macro substitution feature, to be sure to use the production macros, for example.
previewsaves you a click on the preview tab you want.
timeunitallow you to play with a Warp 10 database configured with a different timeunit, and still having a consistent preview.
Of course, there is an automatic completion and hover help for these special comments. Note that
// @endpoint is also available in WarpStudio.
As Warp 10 improves, tooling follow the trend! Feel free to contact us to give your feedback or push new ideas for this extension. You can also submit PR's on the extension github, we'll be happy to review them!