From 71cf5c57e1203adf2d79df92788534e559f5a276 Mon Sep 17 00:00:00 2001 From: Andreas Kurz Date: Sat, 14 Dec 2024 13:54:42 +0000 Subject: [PATCH] feat: integrate clangd This will integrate clangd for better autocompletion and syntax highlighting. Assumption is made that the project build is under /workspace/build with a compile-commands.json living inside. Signed-off-by: Andreas Kurz --- .devcontainer/.clangd | 2 ++ .devcontainer/devcontainer.json | 22 +++++++++++++++------- .devcontainer/post-create.sh | 2 ++ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 .devcontainer/.clangd diff --git a/.devcontainer/.clangd b/.devcontainer/.clangd new file mode 100644 index 0000000000..3e98a4bd84 --- /dev/null +++ b/.devcontainer/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Remove: [-fno-printf-return-value, -mfp16-format=ieee, -fno-reorder-functions, -mthumb-interwork] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a8f2b31fae..636247946b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,12 @@ - { "name": "Bridle", "build": { "dockerfile": "Dockerfile", // Specify version for Zephyr Container // See https://github.com/zephyrproject-rtos/docker-image/releases - "args": { "ZEPHYR_TAG": "v0.27.4" } + "args": { + "ZEPHYR_TAG": "v0.27.4" + } }, // Needed for USB devices in container "privileged": true, @@ -13,23 +14,30 @@ "postStartCommand": "bash ${localWorkspaceFolderBasename}/.devcontainer/post-start.sh /workspace", // Mount and set workspace folder "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspace,type=bind", - "workspaceFolder": "/workspace", + "workspaceFolder": "/workspace", // Username in container - align with Dockerfile - "remoteUser": "user", + "remoteUser": "user", "mounts": [ // Persist installed extensions in container "source=bridle-devcontainer-extensions,target=/home/user/.vscode-server/extensions,type=volume", // Allow attaching USB devices to running container "source=/dev,target=/dev,type=bind" - ],"customizations": { + ], + "customizations": { "vscode": { "settings": { "editor.trimAutoWhitespace": true, - "editor.insertFinalNewline": true + "editor.insertFinalNewline": true, + "clangd.arguments": [ + "--compile-commands-dir=/workspace/build", + "--header-insertion=never" + ], + "clangd.path": "clangd-16" }, "extensions": [ "marus25.cortex-debug", - "ms-vscode.cmake-tools" + "ms-vscode.cmake-tools", + "llvm-vs-code-extensions.vscode-clangd" ] } } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index 59a7bc080a..a27b071d04 100644 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -9,6 +9,8 @@ if [ ! -d ".west" ]; then west init -l $REPO_NAME fi +ln -s $REPO_NAME/.devcontainer/.clangd + west update west bridle-export