[IDE] Getting started with VS Code

Discussion for ongoing CM development. Visible to Donors.
Post Reply
User avatar
Rahlzel
Donor
Donor
Posts: 1160
Joined: 14 Dec 2014, 16:17
Location: USA

[IDE] Getting started with VS Code

Post by Rahlzel » 28 May 2018, 15:19

I've been finding VS Code to be faster and easier than Atom with less extensions needed to get it up-to-speed with other editors.

Image

So far I'm able to do everything Atom can do - compile, open files or lines in Gitlab, etc. But with one added extension I have a lot more review control to Git Blame each line and run more commands on it to see changes.

Here's how to set it up:
  1. Download and install VS Code
  2. Click the Extensions button on the left side (screenshot)
  3. Search for and install "Byond DM", "Gitlens", "Open in Github" (also works with Gitlab), "Project Manager" (optional)
  4. (Optional) Browse more extensions here: https://marketplace.visualstudio.com/VSCode. It's extremely easy to install them - they open in VS Code.
Set up the compiler:
  1. Go to Tasks > Configure Tasks (screenshot)
  2. Fill in the tasks.json with the following:

    Code: Select all

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "DM",
                "type": "shell",
                "command": "D:/GAMES/Byond/bin/dm.exe",
                "args": ["CD:/projects/ColonialMarinesALPHAprivate/ColonialMarinesALPHA.dme"],
                "problemMatcher": {
                    "owner": "dm",
                    "fileLocation": ["relative", "${workspaceFolder}"],
                    "pattern": {
                        "regexp": "[^:]*:(\\d+):(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "severity": 3,
                        "message": 4
                    }
                },
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "presentation": {
                    "reveal": "always",
                    "panel": "new"
                }        }
        ]
    }
  3. Change the "command" and "args" lines with where you have dm.exe and the .dme stored, respectively.
  4. Save the tasks.json and then Tasks > Run Task... > DM. This should start the compile.
  5. To make this even easier and set it as a keybind, go to File > Preferences > Keyboard Shortcuts, search for "task", and edit the "Run Build Task" keybinding to whatever you want. It was F9 for me in Atom so I stuck with F9.
Note that the "problemMatcher" line in the above tasks.json is written well, but it won't work for some reason. It might be for inline error messages and not for compile errors, of which VS Code is not attuned for when using DM. Not sure on that yet. You can still CTRL+Click on error messages in the popup terminal to immediately jump to that file and line and see what's wrong.

Furthermore, you'll probably want to tweak a few of the default program settings to fit your style. Go to File > Preferences > Settings to do this. A file will open split down the center - the right side is the editable side. You just place your settings in here and it will immediately override the defaults on the left. It doesn't care if your last setting has a comma.

Here are my settings:

Code: Select all

{
    "gitlens.advanced.messages": {
        "suppressShowKeyBindingsNotice": true
    },
    "gitlens.gitExplorer.files.layout": "auto",
    "gitlens.historyExplorer.enabled": false,
    "workbench.iconTheme": "vscode-icons",
    "git.autofetch": true,
    "editor.insertSpaces": false,
    "editor.wordWrap": "on",
    "editor.smoothScrolling": true,
    "editor.mouseWheelScrollSensitivity": 2,
    "gitlens.mode.active": "review",
    "workbench.editor.enablePreviewFromQuickOpen": false,
    "workbench.editor.enablePreview": false,
}

Post Reply