Visual Studio Code editor for P1 & P2 (spin & pasm) obsolete
Cluso99
Posts: 18,069
Stephen Moraco has taken over development. Thanks heaps Stephen! His posts start here...
forums.parallax.com/discussion/comment/1509623/#Comment_1509623
Over the next day or so Stephen will be creating a replacement thread and the moderators will shift the later posts to the new thread. I’ll then provide a link here.
Attached is alpha version 0.1.0 of extensions for VS Code to edit P1 & P2 code.
There is a version for Spin/Pasm P1 (for files xxxx.spin) and a Spin/Pasm P2 (for files xxxx.spin2). They use a common color theme included called spin-theme.
Note: P2 has spin1 code support for editing. I am not sure if eric's fastspin compiler will compile this to P2ASM ???
To install, unzip and copy the 3 folders (spin1, spin2 and spin-theme) to %userprofile%/.vscode/extensions and restart VSCode. Then activate the spin-theme using Ctl-K Ctl-T and selecting Spin-Theme.
If you want to change the colors, edit the file ...\spin-theme\themes\spin-theme.json
Please report bugs here. (quite possibly missing some opcodes)
forums.parallax.com/discussion/comment/1509623/#Comment_1509623
Over the next day or so Stephen will be creating a replacement thread and the moderators will shift the later posts to the new thread. I’ll then provide a link here.
Attached is alpha version 0.1.0 of extensions for VS Code to edit P1 & P2 code.
There is a version for Spin/Pasm P1 (for files xxxx.spin) and a Spin/Pasm P2 (for files xxxx.spin2). They use a common color theme included called spin-theme.
Note: P2 has spin1 code support for editing. I am not sure if eric's fastspin compiler will compile this to P2ASM ???
To install, unzip and copy the 3 folders (spin1, spin2 and spin-theme) to %userprofile%/.vscode/extensions and restart VSCode. Then activate the spin-theme using Ctl-K Ctl-T and selecting Spin-Theme.
If you want to change the colors, edit the file ...\spin-theme\themes\spin-theme.json
Please report bugs here. (quite possibly missing some opcodes)
Comments
Or use the built-in terminal to invoke it
If this is not something you would prefer to do on your own, it's probably "not for you"... Creating scripts and such that execute command-line programs is for the most part, something for those that are comfortable with Linux, Win or macOS scripting at the shell level (or maybe javascript or python). The problem with this sort of scripting is it will be dependent on where you store your compilers, assemblers, loaders and other required development software. I could write (and have) a scripted Task, but it would be dependent on my system configuration and would probably cause more angst for other users. This is why IDEs like SimpleIDE and PropTools exist. They work because all of these required programs are contained in a location governed by the IDE's installation process. So far, for P2, there is no single all-in-one IDEesque installation that will accomplish this. We're all either working with what exists or creating that next environment for P2. It's unfortunate, but at this time most of the resources for building P2's development environment are volunteers. But it's also "fortunate" to have those volunteers!
dgately
Actually, the "proper" way is to put all the tools on your PATH, so the scripts don't need to know their location
Cluso, thank you for your contribution. From now on Visual Studio Code + your spin highlighting + fastspin compiler + loadp2 + my json compile and run config has made every other option obsolete. (IMHO)
My setup works perfectly with just "ctrl + shift + b" to compile and run and the terminal pops up in VSC, so no need to have a separate shell open. Seamless!
These are the easy steps I made to make VSC my new P2 "IDE"
2. Download/Install fastspin and loadp2
3. Add the paths to fastspin and loadp2 binaries to the path environment variable
4. Configure the default build task to call fastspin and then loadp2
Here is my "tasks.json" file for my SIDcog P2 project as a reference.
Many thanks for your json file. I’ve been reading how to do that but you’ve done it for me so thanks.
Any idea how to request the filename (eg SIDcogP2) as a variable?
Do you have much VSC experience as i am trying to get the CON/OBJ/VAR/PUB/PRI/DAT scope to remain persistent so i can separate the various keywords into their respective scopes? I know how to see what scopes are current by placing the cursor on various words using Ctl-Sh-P and selecting Developer: Inspect TM Scopes.
If we can get this working, we can add Erics Basic, C, etc addon language easily too.
I am just starting with VS Code and I see the number of users is huge, coming from all the other editors out there. Agreed, this is one time MS has truly helped the masses for free
@Roy,
Thanks for pushing me to look at VS Code. Best thing I’ve done for a while. Haven’t worked out how to run scripts like i do for work in Notepad++ yet but that will come i think.
https://code.visualstudio.com/docs/editor/tasks
Glad it is working out for you, I have been very happy with it for working on Python and Shader (HLSL) code. I will be checking out your spin/pasm related stuff for it soon.
Currently it is quite basic tho I'm working to improve it.
Hoping others will add to it too, so it will improve over time
And I agree.
But where to find the command line tools for P1/Spin1 ?
Access is still via the System Properties dialog: type path in the Search box, click "Edit the system environment variables", and click the "Environment Variables" button. Double click 'path' variable and add the folders where you unzipped the tools
Edit: for fastspin it is maybe better to download spin2gui
Works on Windows and hopefully will work on linux and mac.
Change the command path below if fastspin.exe is in another directory.
Warning: Check there is no tasks.json file present first! If so, make sure you save it elsewhere first.
As far as I can tell so far, there is no way to have multiple tasks.json files present.
Save it as/in %userprofile%/.vscode/extensions/.vscode/tasks.json
To compile in VSC place cursor in the source file and press Ctl-Shift-B which will open a terminal window and compile it. Check for errors.
(see previous post for details of where to install it and note the warning)
Note this means that both P1 and P2 tasks.json files cannot co-exist until I find a way around this
No I have no experience with VSC actually, yesterday was my first time trying it because I wanted to try out your syntax highlighting. (ofcourse, as a developer I have heard a lot about VSC, but never tried it myself). I instantly fell in love with it and everything is intuitive and visually pleasing. 10 minutes googling and fiddling, I had the json file configured to run my SIDcog project with a keyboard shortcut. I love it. I just migrated from PNUT!
I love how the project directory itself is the workspace/project and that you you can have all build related things in the standard ".vscode" directory in your project directory. I don't think it's neccessary to even have a Makefile or an external buildsystem (for C/C++, java.. etc); Just make the json file do everything. All you have to do is to setup the paths to compiler/loaders the right way. I'm not entirely sure about my own claim, but I will try it out. I need to read up on tasks and what can be done.
Why not make some kind of standard script or installer that can download/configure everything for developing P2 code using VSC on any platform. In the end it might be possible to just make a copy of a project directory and run it on any platform that is setup the "standard P2 way".
You do know that you can have ".vscode/tasks.json" in your project directory, right? That way you can have each project configured exactly the way you want it. Then I don't think it's a good idea to have absolute paths to compilers/linkers/loaders. Setting up environment variables makes more sense if you want tasks.json to be deployable on any system for any Propeller user out there. There might be a way of making some kind of template tasks.json that can be automatically configured for each P1/P2-project you start in vscode?!
I've been reading about multiple selectable tasks within the tasks.json file so I will be trying that. And I'll try putting the json file in the project directory again.
As far as I can tell, it doesn't do that. (Unless you want to use a C++ compiler in whole-program mode)
After reading up on this, it seems that you are right. There is no built in mechanism to only compile altered files.
But yes - that does mean installing two more tools on your system (CMake + some kind flavor of make) on top of VSCode and your toolchain. But you'd get a lot more IDE features out of it than you otherwise would.
I haven't done any more with automating VSC but I do edit all my P1 and P2 programs now with VSC. I use VSC daily with Python for work.
VSC handles python and spin/pasm/spin2/pasm2 just fine. I just need to get the P1 and P2 compilers working from VSC. Just not enough hours in the day
I note in todays VSC release there are new buttons for compile and debugging, obviously with 3rd party extensions.
And the VSC release today now has an ARM supported version release too!
I got my P2 yesterday (8/27/2020)
One thing I'm interested in is spin2 integration with Visual Studio Code; is any one working on it; if not, I'm interested in working on it.
Jay
But there is no integration with fastspin/pnut/PropTool for compiling.
IMHO fastspin would be the preference for calling a compiler as it works on all platforms.
Doing this would be great - I'm not really up to the task to do it. You can add a compile button to VSC according to recent docs.