Visual Studio Code supports P2 development on Windows, Mac, Linux (yes, RPi)
Visual Studio Code is an extendable code editor that runs natively on Windows, Linux (inclu. Raspberry Pi), and Macs. There are compilers for P2 Spin/Pasm for Windows (PNut and PropTool) and for Windows, Linux, and Macs (FlexProp).
In support of the P2, we developed a Spin2(Pasm2) extension which is currently in the VSCode marketplace which provides syntax and semantic highlighting for Spin2/Pasm2. This extension once installed will automatically notify you of new update availability whenever new updates are published.
Setting up to develop on your platform of choice is relatively simple:
The steps are explained in detail in the VSCode P2 QuickByte
Basically, they are:
- Install VSCode
- Install the Spin2 extension along with a couple more recommended extensions
- Install your chosen compiler(s)
- Configure your project (add compile and download steps for compiler your using)
- Start iteratively developing and testing your spin2/pasm2 code
NOTE: the Spin2 extension is new since the Spin (for P1) extension was released. So if you want P1 and P2 support, install them both. Eventually, as I wrap up current projects I'll backport this latest extension to the P1 but this is likely months away...
Comments
- (1) Language syntax highlighting - our SPIN2/PASM2 languages together have some 800ish keywords... I'm only partway done adding them. I have created the definition for the autoclose behavior for this language and that's working well. Work in progress
- (2) Outline navigation of the current file does not work for SPIN/PASM. I've started to add it but my initial attempt is not yet working. I found an example project to start from. This will probably be one, maybe two, pages of code. This is not a large effort. (it's written in TypeScript). Work in progress
- (3) I've been playing with packaging the extensions. I finally know how to, and have successfully generated my first .vsix files. These are what get distributed to the marketplace, eventually, but for now, I'll just post them here when we have updates. Work in Progress
- (4) The theme needs to be updated once the syntax highlighting is working as that creates the names of objects that can be colored. Work in progress
- (5) We need to add the compile and download mechanism yet. Setting it up and testing - Work in Progress. I've worked in vscode environments where it watches for file saves and then automatically compiles. This seems like what we want, right? (with downloads only attempted when compile succeeds, of course.)
I just wanted to indicate that progress is being made. If any of you happen to have experience building vscode extensions or happen to know someone that does that would be willing to help, please contact me. I'd welcome the help! Of course, I'll keep pushing on this.
I'm planning on doing the next release for us all to play with when I get (1) further along and (4) sync'd to it.
After that, I'll push new updates when we fix things we've found and/or as (2) and (5) get completed.
I'm using what I have so far, daily! It is getting better... it's just taking time!
Regards,
Stephen
I'm attaching the latest vscode extension. It's a zip file. Download it and unzip it.
Then you can do a manual install by using the command-line shown in these INSTALL instructions
You may want to review what vscode extensions you have installed and then remove any earlier versions. (They are likely "spin1", "spin2", and "spin-theme" in your extensions directory.)
Please let me know what you think of this so far. This should work pretty well with your favorite theme. I have included the "Spin2 IronSheep" theme which is what I use during verification of the work. It's pretty colorful so I can tell quickly which parts are working. However, this is what I'm also using day-2-day so it functions well.
Once you have this installed, then please take the time to find it in your list of installed extensions. Once you find it, you'll see three tabs on that page, please review them as I'll change the content there with each new release. They are "Details", "Feature Contributions" and "Changelog". Details has operational notes for you while the Changelog has specifics about what's working, what's not, problems we already know of, etc. Also, you'll see a list of things we are next working on. See it is things you'll want to review each time, right?
Alright. Enjoy! Please let me know if you like the progress so far and where it's heading.
Regards,
Stephen
Ken Gracey
Enjoy!
I'll let you know how it goes but it will not be until mid-week as I have to concentrate on getting some other things done while fitting in with work.
This new version v0.2.0 complete's the Pasm2 and Spin2 language definition as well as add all Streamer constants and SmartPin constants.
Let's exercise this and please let me know if you see things that could/should be improved.
I'm taking a break now since this is fully functional to get back to my RGB LED Matrix driver and hopefully scheduling PCB production.
Meanwhile, you can advise what you think the priority for my next efforts on this extension should be from amongst items that are shown in the ChangeLog "Unreleased" section.
Please tell me which are most important to you in how you use vscode! If I'm missing something important, please note that for me too!
Regards,
Stephen
works nicely, outline is a great feature too!
Windows installation notes
Unzip file
Unzip the zip file to extract "spin2-?.?.?.vsix" and copy/move it to your windows %userprofile% folder (ie C:\Users\<username>\ so mine is C:\Users\Ray\ )
Install vscode extension (manually)
Open a windows command prompt (Start | Windows System | Command Prompt)
C:\Users\Ray>
enter "code --install-extension spin2-?.?.?.vsix" without the double-quotes (replace the '?' wildcards with the version number)
Close the command prompt window and we're done.
Here is the command prompt dialog (note the warning)
Just noticed that some color formatting is being lost, possibly due to nested if statements. See the attached jonnymac serial driver from line 398 onwards.
Thanks for the heads up! I've also found a couple of things. Give me a couple of days and I'll roll in updates... And by all means, keep reporting anything any of you find!
Well, that's a challenging case!
The issue is that "\" is recognized as a start of a string with a contained \" (escaped double quote) so the end of the string is not matched. I'm looking to see if I can build a stronger definition of strings that wouldn't suffer this issue. We'll see.
For now, this gets us past the issue. v0.2.1 attached!
Installed v0.2.1 today.
Noticed this problem - maybe another case of "\" ???
---
No mascot today.
Erco why is there a mountain lion studying your car?
I'll bet you are correct! Sigh...
This will be a couple of days. I'm trying to get my Hub75 driver into P2 Obex later this week. I'll look at this after.
Thanks for the testing, use, and heads up! Please keep reporting anything you find.
Enjoy!
and just this line
Thanks for posting what you’re finding
Have you tried Stephens addon? Works nicely. It would be good to extend this to add the compilation options/button. Stephen is a bit preoccupied with the LED panels currently.
I didn't realise it didn't do .spin files as I just tried.
Perhaps you could detail how you added the compile/run tasks here please
The spin extension I have from the Marketplace is by Entomy. I don't see any others. The one you mentioned involves getting from github and installing I guess. I didn't want to get into that level of learning yet. I'm finding enough to learn just patching together miscellaneous stuff to get software going for my P2 board.
My post a couple back shows how to add .spin2 recognition to the .spin VSC extension, but I also found where that is in the settings files, too, if you need that method.
Now (minor annoyance, not problem) I'm looking for a way to add recognition of __asm { } to the C/C++ extension I have from Microsoft. I get squiggly line warnings of non-recognition even though the actual code is fine. I've been poking around VSC and the internet with no luck so far. The __asm { } thing is a feature of Eric's FlexProp and not known by Microsoft's extension of course. So it's up to a wanna be gearhead to patch things together. Fun, but ......
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "RunSpin",
"type": "shell",
"command": "flexrun.sh ${fileBasenameNoExtension}",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": false,
"clear": false
},
"problemMatcher": []
},
{
"label": "RunSpin2",
"type": "shell",
"command": "flexrun2.sh ${fileBasenameNoExtension}",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": false,
"clear": false
},
"problemMatcher": []
},
At the lower right of the screen there's a little area for notifications, tweeting, choosing encoding modes, etc. In there is a selector for language association. I now have .spin2 files matched up with .spin so the code highlighter extension works for both.
Otherwise you can (Cmd-P on Mac) search for "language specific settings" and get into this .json, which is where it put my additional association apparently.
{
"workbench.colorTheme": "Default Light+",
"files.autoSave": "off",
"explorer.confirmDelete": false,
"files.associations": {
"*.spin2": "spin"
},
"[c]": {
"editor.wordBasedSuggestions": false,
"editor.suggest.insertMode": "replace",
"editor.semanticHighlighting.enabled": true
}
}
dgately