Skip to content

Commit

Permalink
feat: integrate clangd
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andreaskurz committed Dec 14, 2024
1 parent 93f9b33 commit 71cf5c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .devcontainer/.clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
Remove: [-fno-printf-return-value, -mfp16-format=ieee, -fno-reorder-functions, -mthumb-interwork]
22 changes: 15 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@

{
"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,
"postCreateCommand": "bash ${localWorkspaceFolderBasename}/.devcontainer/post-create.sh /workspace ${localWorkspaceFolderBasename}",
"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"
]
}
}
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 71cf5c5

Please sign in to comment.