Visual Studio Code editor for P1 & P2 (spin & pasm)

Cluso99Cluso99 Posts: 14,911
edited 2019-04-22 - 11:54:32 in Propeller 2
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)

VSCode-spin-v0.1.0.jpg
My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
Website: www.clusos.com
Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)

Comments

  • -reserved-
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Question, looking to use the p1 version. Will it. compile and download to the prop1?
    That's not an explosion! That's an unscheduled rapid disassembly!
  • Cluso99Cluso99 Posts: 14,911
    edited 2019-04-22 - 14:07:34
    Question, looking to use the p1 version. Will it. compile and download to the prop1?
    No. It’s just an editor, though it runs on windoze, linux and mac, and free.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Would it be possible to modify the extension to compile Spin? Could I do it with little to no experience making extensions?
    That's not an explosion! That's an unscheduled rapid disassembly!
  • Cluso99Cluso99 Posts: 14,911
    edited 2019-04-22 - 16:50:45
    Would it be possible to modify the extension to compile Spin? Could I do it with little to no experience making extensions?
    Trying to be polite, but if you have to ask, then the answer is probably no. I don’t know VSC enough yet to know if it’s even possible. It’s not how i would tackle it tho. I’d call an existing compiler instead - why spend hundreds of hours reinventing what’s been done?
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Cluso99, that's probably what he's asking. Some way to get the menu item compile to call the command line compiler and display the info.
  • Yeah, interesting, but I really prefer to edit and compile without changing programs in between. Really neat, though!
    That's not an explosion! That's an unscheduled rapid disassembly!
  • Wuerfel_21Wuerfel_21 Posts: 266
    edited 2019-04-22 - 20:12:57
    Just set up your compiler in (project folder)/.vscode/launch.json as ususal
    Or use the built-in terminal to invoke it
  • Would it be possible to modify the extension to compile Spin? Could I do it with little to no experience making extensions?
    You probably would not want to use the editor extension to compile .spin or .spin2 code. But, you can create a VSC (Visual Studio Code) Task, which can execute any command-line such as fastspin compiler or openspin, loaders, etc... If you Google something like "How to create a Virtual Studio Code Task", you'll find examples of how to do this.

    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
    Livermore, CA (50 miles SE of San Francisco)
  • Wuerfel_21Wuerfel_21 Posts: 266
    edited 2019-04-23 - 08:28:02
    dgately wrote: »
    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.

    Actually, the "proper" way is to put all the tools on your PATH, so the scripts don't need to know their location
  • Wuerfel_21 wrote: »
    dgately wrote: »
    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.
    Actually, the "proper" way is to put all the tools on your PATH, so the scripts don't need to know their location
    Exactly! But as evidenced by many forum postings, using a $PATH is within the same category of activities done by those who write shell scripts, execute programs from the command line, create IDE extensions, etc...
    Livermore, CA (50 miles SE of San Francisco)
  • Visual Studio Code is fantastic... Is that REALLY an open source, small footprint, fast, good looking, free, platform independent and flexible code editor from MICROSOFT?! I don't think I have ever used more than a couple of those words to describe a Microsoft product ever. This MUST be an alternative reality!!

    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) :smiley:

    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"
    1. Install Cluso's spin highlighting in VSC
    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.
    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Compile",
                "type": "shell",
                "command": "fastspin -2 SIDcogP2.spin2"
            },
            {
                "label": "Run",
                "type": "shell",
                "command": "loadp2 SIDcogP2.binary",
                "dependsOn": [
                    "Compile"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
    

    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Cluso99Cluso99 Posts: 14,911
    edited 2019-04-24 - 00:53:14
    Ahle2,
    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 :smiley:

    @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.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Here is a link for how to automate the tasks, including windows and linux commands, default filenames, paths, getting input parameters from the user, etc. I'm reading thru this now ;)

    https://code.visualstudio.com/docs/editor/tasks
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • @Cluso99
    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.
  • Roy Eltham wrote: »
    @Cluso99
    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 :smiley:
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Question, looking to use the p1 version. Will it. compile and download to the prop1?

    And I agree.
    But where to find the command line tools for P1/Spin1 ?

  • rosco_pcrosco_pc Posts: 317
    edited 2019-04-24 - 05:17:01
    openspin and/or fastspin. Unzip them somewhere and add them to your CMD path (for WIN10):

    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
    Stockholm, Sweden
    I am only an egg -- Stranger in a Strange land, Robert A. Heinlein
  • Cluso99Cluso99 Posts: 14,911
    edited 2019-04-24 - 06:18:35
    This json file will build a P1 binary using c:/Propeller/fastspin.exe
    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 https://go.microsoft.com/fwlink/?LinkId=733558 
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Compile",
                "type": "shell",
                "windows": {
                    "command": "C:/Propeller/fastspin ${file}"
                },
                "linux": {
                    "command": "C:/Propeller/fastspin ${file}"
                },
                "osx": {
                    "command": "C:/Propeller/fastspin ${file}"
                },
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
    
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • This json file is for compiling P2 using fastspin.
    (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 :(
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • @Cluso99

    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! :smiley:

    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".


    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Thinking a little mor about it, a Parallax supported VSC standard config might be exactly what will make the P2 a worthy alternative for "serious" embedded developers. VSC is by far the most beloved editor in 2019 according to different surveys. Everybody seems to love it. And because it is the defacto standard nowdays, developers will feel at home right away. Configured the right way it becomes a fully featured IDE.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Cluso99 wrote: »
    This json file will build a P1 binary using c:/Propeller/fastspin.exe
    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 https://go.microsoft.com/fwlink/?LinkId=733558 
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Compile",
                "type": "shell",
                "windows": {
                    "command": "C:/Propeller/fastspin ${file}"
                },
                "linux": {
                    "command": "C:/Propeller/fastspin ${file}"
                },
                "osx": {
                    "command": "C:/Propeller/fastspin ${file}"
                },
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
    

    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?!
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • Ahle2 wrote: »
    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 thought that I tried it in the project directory but it could have been before I got it working.
    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.

    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Ahle2 wrote: »
    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.

    As far as I can tell, it doesn't do that. (Unless you want to use a C++ compiler in whole-program mode)

  • @Wuerfel_21
    After reading up on this, it seems that you are right. There is no built in mechanism to only compile altered files.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX
  • To get the most out of VSCode with a C/C++ project, you'd want to combine it with CMake and the CMake Tools VSCode extension: https://vector-of-bool.github.io/2018/07/20/cmt-1.1.0.html
    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.
    David
    PropWare: C++ HAL (Hardware Abstraction Layer) for PropGCC; Robust build system using CMake; Integrated Simple Library, libpropeller, and libPropelleruino (Arduino port); Instructions for Eclipse and JetBrain's CLion; Example projects; Doxygen documentation
    CI Server: http://david.zemon.name:8111/?guest=1
Sign In or Register to comment.