利用者:Brita/Configs/VSCode

提供: wiki
< 利用者:Brita‎ | Configs
2018年5月13日 (日) 03:45時点におけるwiki>Britaによる版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Configuring and Using VSCode

Visual Studio Code is a lightweight code editing environment that supports C, C++, Python (among many others) and has integrated debugging and Git support.

It is available for Windows, MacOs and Linux.

This page shows how to setup for both C/C++ Blender development and for Python addons.

Installing

There are two versions to choose from when downloading VSCode:

To use the free and open source version, you need to build it yourself using the following instructions: https://github.com/Microsoft/vscode/wiki/How-to-Contribute

You will also need to enable the marketplace extension gallery manually by adding the following to ~/vscode/product.json;

"extensionsGallery": {
	"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
	"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
	"itemUrl": "https://marketplace.visualstudio.com/items"
}


Basic Configuration

In File > Preferences > Settings you can find a multitude of settings and commonly used options to set VSCode to your liking.

You might want to opt out of sending data to Microsoft as at the moment that is not the default.

    "telemetry.enableTelemetry": false,     // disable data sending to Microsoft
    "telemetry.enableCrashReporter": false,
    "extensions.autoUpdate": false,         // update only by choice


Setup for Core Blender development

Install the following extensions:

  • C/C++ (ms-vscode.cpptools) - language support for C and C++
  • CMake (twxs.cmake) - language support for CMake files (syntax highlighting, etc)
  • CMake Tools (twxs.cmake) - workflow tools for CMake (documentation)
  • Note: As of CMake Tools version 0.11.0 it is no longer necessary to also install cmake-tools-helper

Setup CMake Tools

Command Palette (Ctrl+Shift+P):

> CMake: Scan for Kits
> CMake: Select a Kit
> CMake: Set the current build variant
> CMake: Configure
> CMake: Select a Target to Debug

Connect the Cpp and CMake Tools extensions

This step is needed so that the Cpp Extension, which does the syntax highlighting and symbol lookup knows what is the current CMake setup in regard to the include paths and variables (eg. WITH_CYCLES).

File Search (Ctrl+P) for c_cpp_properties.json (should be in the project's .vscode folder)

Find the configuration you are using (eg. "Linux") and add the path to the file compile_commands.json that is generated by CMake in the blender-build folder. Example:

   "name": "Linux",
    ....
   "compileCommands": "/home/stitch/workspace/blenderStuff/blender_source/blender-build/compile_commands.json",

Running

To launch Blender with F5, you can setup the executable to launch in VSCode's launch settings.

Command Palette (Ctrl+Shift+P): > Debug: open launch.json
Add the path to the program and optionally some command line arguments.

    "program": "${command:cmake.launchTargetPath}",
    "args": ["--enable-copy-on-write"],

Git integration

svn?


Setup for Python Addon development

bla


Updating VSCode and the extensions

For the free software version:

cd ~/packages/vscode
git pull
yarn
yarn run watch


Full User Settings

{
  "window.zoomLevel": -0.9,
  "terminal.integrated.fontSize": 13,
  "editor.fontSize": 13,

  "editor.insertSpaces": false,
  "editor.rulers": [80, 120],
  "editor.renderWhitespace": "boundary",
  "editor.autoClosingBrackets": false,

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "punctuation",
        "settings": {
          "fontStyle": "bold",
        }
      },
      {
        "scope": "meta.block",
        "settings": {
        }
      },
    ]
  },

  "search.location": "panel",

  "workbench.iconTheme": "vscode-icons",
  "workbench.editor.tabSizing": "shrink",
  "workbench.editor.enablePreview": true,
  "workbench.editor.enablePreviewFromQuickOpen": true,
  "workbench.statusBar.feedback.visible": false,
  "workbench.panel.defaultLocation": "right",

  "debug.hideActionBar": false,
  "debug.inlineValues": false,

  "cmake.sourceDirectory": "${workspaceRoot}",
  "cmake.buildDirectory": "${workspaceRoot}/../blender-build",
  "cmake.buildBeforeRun": false,
  "cmake.saveBeforeBuild": false,
  "cmake.defaultVariants": {
    "buildType": {
      "default$": "debug",
      "description$": "The build type to use",
      "debug": {
        "oneWordSummary$": "Debug",
        "description$": "Emit debug information without performing optimizations",
        "buildType": "Debug"
      },
      "release": {
        "oneWordSummary$": "Release",
        "description$": "Enable optimizations, omit debug info",
        "buildType": "Release"
      }
    }
  },

  "gitlens.advanced.messages": {
      "suppressCommitHasNoPreviousCommitWarning": false,
      "suppressCommitNotFoundWarning": false,
      "suppressFileNotUnderSourceControlWarning": false,
      "suppressGitVersionWarning": false,
      "suppressLineUncommittedWarning": false,
      "suppressNoRepositoryWarning": false,
      "suppressResultsExplorerNotice": false,
      "suppressShowKeyBindingsNotice": true
  },
  "gitlens.advanced.telemetry.enabled": false,
  "gitlens.advanced.blame.delayAfterEdit": 0,
  "git.countBadge": "off",
  "gitlens.codeLens.recentChange.enabled": false,
  "gitlens.codeLens.authors.enabled": false,

  "telemetry.enableTelemetry": false,
  "telemetry.enableCrashReporter": true,
  "extensions.autoUpdate": false,
}