Adds support cpp to vscode (#1828)

Co-authored-by: Stefan Agner <stefan@agner.ch>
This commit is contained in:
dentra 2021-06-15 01:45:22 +03:00 committed by GitHub
parent 93f8ee7e60
commit c411043681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 26 deletions

View file

@ -2,16 +2,29 @@
"name": "ESPHome Dev",
"context": "..",
"dockerFile": "../docker/Dockerfile.dev",
"postCreateCommand": "mkdir -p config && pip3 install -e .",
"runArgs": ["--privileged", "-e", "ESPHOME_DASHBOARD_USE_PING=1"],
"postCreateCommand": [
"script/devcontainer-post-create"
],
"runArgs": [
"--privileged",
"-e",
"ESPHOME_DASHBOARD_USE_PING=1"
],
"appPort": 6052,
"extensions": [
// python
"ms-python.python",
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml"
// yaml
"redhat.vscode-yaml",
// cpp
"ms-vscode.cpptools",
// editorconfig
"editorconfig.editorconfig",
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.pythonPath": "/usr/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
@ -19,7 +32,7 @@
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.shell.linux": "/bin/bash",
"terminal.integrated.defaultProfile.linux": "/bin/bash",
"yaml.customTags": [
"!secret scalar",
"!lambda scalar",
@ -27,6 +40,18 @@
"!include_dir_list scalar",
"!include_dir_merge_list scalar",
"!include_dir_merge_named scalar"
]
],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.pyc": {
"when": "$(basename).py"
},
"**/__pycache__": true
},
"files.associations": {
"**/.vscode/*.json": "jsonc"
},
"C_Cpp.clang_format_path": "/usr/bin/clang-format-11",
}
}

View file

@ -7,7 +7,7 @@ insert_final_newline = true
charset = utf-8
# python
[*.{py}]
[*.py]
indent_style = space
indent_size = 4
@ -25,4 +25,10 @@ indent_size = 2
[*.{yaml,yml}]
indent_style = space
indent_size = 2
quote_type = single
quote_type = single
# JSON
[*.json]
indent_style = space
indent_size = 2

View file

@ -1,13 +1 @@
FROM esphome/esphome-base-amd64:3.4.0
COPY . .
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3-wheel \
net-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workspaces
ENV SHELL /bin/bash
FROM esphome/esphome-lint:1.1

View file

@ -28,11 +28,6 @@ def write_version(version: str):
r"ARG BUILD_FROM=esphome/esphome-base-amd64:.*",
f"ARG BUILD_FROM=esphome/esphome-base-amd64:{version}",
)
sub(
"docker/Dockerfile.dev",
r"FROM esphome/esphome-base-amd64:.*",
f"FROM esphome/esphome-base-amd64:{version}",
)
sub(
"docker/Dockerfile.lint",
r"FROM esphome/esphome-lint-base:.*",

18
script/devcontainer-post-create Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
set -e
# set -x
mkdir -p config
pip3 install -e .
cpp_json=.vscode/c_cpp_properties.json
if [ ! -f $cpp_json ]; then
echo "Initializing PlatformIO..."
pio init --ide vscode --silent
sed -i "/\\/workspaces\/esphome\/include/d" $cpp_json
else
echo "Cpp environment already configured. To reconfigure it you could run one the following commands:"
echo " pio init --ide vscode -e livingroom8266"
echo " pio init --ide vscode -e livingroom32"
fi