Dev:Visual Studio Code

From Twilight Princess Wiki
Jump to navigation Jump to search

We strongly recommend using VS Code as it is a lightweight, modern, cross-platform & open source Editor with a variety of plugins.

Our Coding Guidelines were designed to work with VSCode in the following configuration, of course this is just an example and doesn't have to be identical to your setup; there's room for personal preferences as long as the core functions remain intact.

Plugins

C/C++ Tools

This plugin is a powerful tool that helps us to find mistakes in our code before even attempting to build, furthermore does it support formatting with our .clang-format configuation file from our Guidelines.

Setup:

  • In VSCode hit Ctrl+Shift+X
  • Search for "ms-vscode.cpptools"
  • Click install
  • Go to your main Settings by pressing Ctrl+,
  • Search for "Default formatter" and select "ms-vscode.cpptools"
  • Expand the "Extensions" and then "C/C++" menu
  • Set the "Clang_format_fallback Style" to "Chromium"
  • And "Clang_format_style" to "file"
  • Leave other clang related settings default since most of them override the .clang-format configuration!
  • Open a source file and you should find a "Win32" at the bottom right, click that and select "Edit Configurations (JSON)"

Replace your configuration with this (or simply add the GC section to yours), make sure to replace the absolute paths with whatever is the case for you.

{
    "configurations": [
        {
            "name": "GC",
            "includePath": [
                "${workspaceFolder}/externals/libtp_rel/include/",
                "${workspaceFolder}/include/"
            ],
            "defines": [
                "_BUILDID=\"YYYYMMDDHHmm\"",
                "_PROJECT_NAME=\"CHECK-MAKEFILE\"",
                "_VERSION=\"x.y.z\"",
                "_VARIANT=\"MKFILE\""
            ],
            "compilerPath": "D:/bin/devKit/devkitPPC/bin/powerpc-eabi-g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x86",
            "browse": {
                "limitSymbolsToIncludedHeaders": true
            },
            "compilerArgs": []
        }
    ],
    "version": 4
}

I encourage you to check the main settings menu and adjust some of the formatter specific settings to your likings, we've configured VSC to use cpp-tools as its formatter but not when it should be triggered. I have VSC set up to format on save, paste and using the button combo Shift+Alt+F (default)