pw_ide: Visual Studio Code support
Provides settings, tasks, and recommended extensions for VS Code.
The intent is that (at least for now) downstream projects would copy
this configuration to their own projects and modify it for their
purposes. Over time, it may become challenging to keep up with upstream
changes, but VS Code doesn't provide a good mechanism for cascading
settings, so we will have to figure out some other solution in the
future.
Change-Id: I14954578ddd91ad511b7cf61c6858804aaf2281b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/110260
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Commit-Queue: Chad Norvell <chadnorvell@google.com>
diff --git a/.gitignore b/.gitignore
index 2837f1c..7578551 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,6 @@
.ijwb/
.project
.cproject
-.vscode
# Clangd directories
.clangd/
/.cache/clangd/
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..809da2e
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,13 @@
+{
+ "recommendations": [
+ "llvm-vs-code-extensions.vscode-clangd",
+ "ms-python.python",
+ "npclaudiu.vscode-gn",
+ "persidskiy.vscode-gnformat",
+ "zxh404.vscode-proto3",
+ "josetr.cmake-language-support-vscode"
+ ],
+ "unwantedRecommendations": [
+ "ms-vscode.cpptools"
+ ]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..970d640
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,114 @@
+{
+ // Global settings
+ "editor.detectIndentation": false,
+ "editor.rulers": [80],
+ "editor.tabSize": 2,
+ "files.associations": {
+ "*.inc": "cpp"
+ },
+ "files.exclude": {
+ "**/*.egg-info": true,
+ "**/.mypy_cache": true,
+ "**/__pycache__": true,
+ ".cache": true,
+ ".cipd": true,
+ ".environment": true,
+ ".presubmit": true,
+ ".pw_ide": true,
+ ".pw_ide.user.yaml": true,
+ "bazel-bin": true,
+ "bazel-out": true,
+ "bazel-pigweed": true,
+ "bazel-testlogs": true,
+ "build": true,
+ "environment": true,
+ "node_modules": true,
+ "out": true
+ },
+ "files.insertFinalNewline": true,
+ "files.trimTrailingWhitespace": true,
+ "search.useGlobalIgnoreFiles": true,
+
+ // Integrated terminal settings
+ "terminal.integrated.env.linux": {
+ "CIPD_CACHE_DIR": "${userHome}/.cipd-cache-dir",
+ "PATH": "${workspaceFolder}/out/host/host_tools:${workspaceFolder}/environment/pigweed-venv/bin:${workspaceFolder}/environment/cipd/packages/luci:${workspaceFolder}/environment/cipd/packages/bazel:${workspaceFolder}/environment/cipd/packages/python/bin:${workspaceFolder}/environment/cipd/packages/python:${workspaceFolder}/environment/cipd/packages/arm/bin:${workspaceFolder}/environment/cipd/packages/arm:${workspaceFolder}/environment/cipd/packages/pigweed/bin:${workspaceFolder}/environment/cipd/packages/pigweed:${workspaceFolder}/environment/cipd:${env:PATH}",
+ "PW_ARM_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/arm",
+ "PW_BAZEL_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/bazel",
+ "PW_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd",
+ "PW_DEFAULT_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/default", "PW_LUCI_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/luci",
+ "PW_PACKAGE_ROOT": "${workspaceFolder}/environment/packages",
+ "PW_PIGWEED_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/pigweed",
+ "PW_PROJECT_ROOT": "${workspaceFolder}/.",
+ "PW_PYTHON_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/python",
+ "PW_ROOT": "${workspaceFolder}/.",
+ "VIRTUAL_ENV": "${workspaceFolder}/environment/pigweed-venv",
+ "_PW_ACTUAL_ENVIRONMENT_ROOT": "${workspaceFolder}/environment",
+ "_PW_ENVIRONMENT_CONFIG_FILE": "${workspaceFolder}/pw_env_setup/config.json",
+ "_PW_ROSETTA": "1"
+ },
+ "terminal.integrated.env.osx": {
+ "CIPD_CACHE_DIR": "${userHome}/.cipd-cache-dir",
+ "PATH": "${workspaceFolder}/out/host/host_tools:${workspaceFolder}/environment/pigweed-venv/bin:${workspaceFolder}/environment/cipd/packages/luci:${workspaceFolder}/environment/cipd/packages/bazel:${workspaceFolder}/environment/cipd/packages/python/bin:${workspaceFolder}/environment/cipd/packages/python:${workspaceFolder}/environment/cipd/packages/arm/bin:${workspaceFolder}/environment/cipd/packages/arm:${workspaceFolder}/environment/cipd/packages/pigweed/bin:${workspaceFolder}/environment/cipd/packages/pigweed:${workspaceFolder}/environment/cipd:${env:PATH}",
+ "PW_ARM_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/arm",
+ "PW_BAZEL_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/bazel",
+ "PW_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd",
+ "PW_DEFAULT_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/default",
+ "PW_LUCI_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/luci",
+ "PW_PACKAGE_ROOT": "${workspaceFolder}/environment/packages",
+ "PW_PIGWEED_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/pigweed",
+ "PW_PROJECT_ROOT": "${workspaceFolder}/.",
+ "PW_PYTHON_CIPD_INSTALL_DIR": "${workspaceFolder}/environment/cipd/packages/python",
+ "PW_ROOT": "${workspaceFolder}/.",
+ "VIRTUAL_ENV": "${workspaceFolder}/environment/pigweed-venv",
+ "_PW_ACTUAL_ENVIRONMENT_ROOT": "${workspaceFolder}/environment",
+ "_PW_ENVIRONMENT_CONFIG_FILE": "${workspaceFolder}/pw_env_setup/config.json",
+ "_PW_ROSETTA": "1"
+ },
+
+ // Disable task auto detection
+ "grunt.autoDetect": "off",
+ "gulp.autoDetect": "off",
+ "jake.autoDetect": "off",
+ "npm.autoDetect": "off",
+ "typescript.tsc.autoDetect": "off",
+
+ // Build systems settings
+ "[gn]": {
+ "editor.defaultFormatter": "persidskiy.vscode-gnformat"
+ },
+
+ // C/C++ settings
+ "clangd.path": "${workspaceFolder}/.pw_ide/clangd",
+ "clangd.arguments": [
+ "--background-index",
+ "--clang-tidy",
+ "--compile-commands-dir=${workspaceFolder}/.pw_ide"
+ ],
+ "clangd.onConfigChanged": "restart",
+ "C_Cpp.intelliSenseEngine": "Disabled",
+ "[cpp]": {
+ "editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
+ },
+
+ // Python settings
+ "python.defaultInterpreterPath": "${workspaceFolder}/.pw_ide/python",
+ "python.envFile": "${workspaceFolder}/.vscode/.env",
+ "python.formatting.provider": "yapf",
+ "python.formatting.yapfPath": "${workspaceFolder}/.pw_ide/python-bin/yapf",
+ "[python]": {
+ "editor.tabSize": 4
+ },
+
+ // Other languages settings
+ "[proto3]": {
+ "editor.defaultFormatter": "zxh404.vscode-proto3"
+ },
+ "[restructuredtext]": {
+ "editor.quickSuggestions": {
+ "comments": "off",
+ "strings": "off",
+ "other": "off"
+ }
+ }
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..39bf54a
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,100 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "type": "shell",
+ "label": "Pigweed IDE: Format",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw format --fix'",
+ "problemMatcher": []
+ },
+ {
+ "type": "shell",
+ "label": "Pigweed IDE: Presubmit",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw presubmit'",
+ "problemMatcher": []
+ },
+
+ {
+ "label": "Pigweed IDE: Set Python Virtual Environment",
+ "command": "${command:python.setInterpreter}",
+ "problemMatcher": []
+ },
+ {
+ "label": "Pigweed IDE: Restart Python Language Server",
+ "command": "${command:python.analysis.restartLanguageServer}",
+ "problemMatcher": []
+ },
+ {
+ "label": "Pigweed IDE: Restart C++ Language Server",
+ "command": "${command:clangd.restart}",
+ "problemMatcher": []
+ },
+
+ {
+ "type": "shell",
+ "label": "gn gen out",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'gn gen out --export-compile-commands'",
+ "problemMatcher": []
+ },
+ {
+ "type": "shell",
+ "label": "pw ide cpp --process out/compile_commands.json",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw ide cpp --process out/compile_commands.json'",
+ "problemMatcher": []
+ },
+ {
+ "type": "shell",
+ "label": "pw ide setup",
+ "command": "python3 ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw ide setup'",
+ "problemMatcher": []
+ },
+
+ {
+ "label": "Pigweed IDE: Setup",
+ "dependsOrder": "sequence",
+ "dependsOn": [
+ "pw ide setup",
+ "Pigweed IDE: Set Python Virtual Environment",
+ "Pigweed IDE: Restart C++ Language Server",
+ ],
+ "problemMatcher": []
+ },
+ {
+ "label": "Pigweed IDE: Update Compilation Databases",
+ "dependsOrder": "sequence",
+ "dependsOn": [
+ "gn gen out",
+ "pw ide cpp --process out/compile_commands.json",
+ "Pigweed IDE: Restart C++ Language Server",
+ ],
+ "problemMatcher": []
+ },
+
+ {
+ "type": "shell",
+ "label": "Pigweed IDE: Current C++ Code Analysis Target",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw ide cpp'",
+ "problemMatcher": []
+ },
+ {
+ "type": "shell",
+ "label": "Pigweed IDE: List C++ Code Analysis Targets",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw ide cpp --list'",
+ "problemMatcher": []
+ },
+ {
+ "type": "shell",
+ "label": "Pigweed IDE: Set C++ Code Analysis Target",
+ "command": "${workspaceFolder}/.pw_ide/python ${workspaceFolder}/pw_ide/py/pw_ide/activate.py -x 'pw ide cpp --set ${input:target}'",
+ "problemMatcher": []
+ }
+ ],
+
+ "inputs": [
+ {
+ "id": "target",
+ "type": "promptString",
+ "description": "C++ code analysis target"
+ }
+ ]
+}