From: AdrianF <adrian.freihofer@siemens.com>
To: openembedded-core@lists.openembedded.org
Cc: Adrian Freihofer <adrian.freihofer@siemens.com>
Subject: [PATCH 12/15] devtool: ide-sdk: format C/C++ with clangd when .clang-format is present
Date: Wed, 9 Sep 2026 23:53:12 +0200 [thread overview]
Message-ID: <20260909215337.89106-13-adrian.freihofer@siemens.com> (raw)
In-Reply-To: <20260909215337.89106-1-adrian.freihofer@siemens.com>
From: Adrian Freihofer <adrian.freihofer@siemens.com>
Add "[cpp]"/"[c]" defaultFormatter and editor.formatOnSave settings
pointing at the clangd VSCode extension, so devtool ide-sdk-generated
workspaces auto-format on save using the recipe's own .clang-format
style.
Only enabled when clangd is the active IntelliSense engine
(IDE_SDK_INTELLISENSE == "clangd", which also gates whether the clangd
extension is recommended/installed) and a .clang-format file exists in
the recipe source tree, so gcc/cpptools recipes and recipes without a
.clang-format are unaffected.
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
scripts/lib/devtool/ide_plugins/ide_code.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py
index 8a8ab8bf3d..f8036f15de 100644
--- a/scripts/lib/devtool/ide_plugins/ide_code.py
+++ b/scripts/lib/devtool/ide_plugins/ide_code.py
@@ -248,6 +248,19 @@ class IdeVSCode(IdeBase):
# Avoid cpptools (if also installed) fighting clangd over IntelliSense.
settings_dict["C_Cpp.intelliSenseEngine"] = "disabled"
+ def __vscode_settings_format(self, settings_dict, modified_recipe):
+ # clangd is the only formatter wired up here, so only enable it when
+ # clangd is actually the active IntelliSense engine (its extension is
+ # recommended/available).
+ if not (modified_recipe.ide_sdk_intellisense == 'clangd' and modified_recipe.build_tool.is_c_cpp):
+ return
+ # Respect the project's own formatting style only if it opted in.
+ if not os.path.isfile(os.path.join(modified_recipe.real_srctree, '.clang-format')):
+ return
+ settings_dict["[cpp]"] = {"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"}
+ settings_dict["[c]"] = {"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"}
+ settings_dict["editor.formatOnSave"] = True
+
def vscode_settings(self, modified_recipe, image_recipe):
files_hide = {
"**/.git/**": True,
@@ -282,6 +295,7 @@ class IdeVSCode(IdeBase):
self.__vscode_settings_meson(settings_dict, modified_recipe)
self.__vscode_settings_kernel_module(settings_dict, modified_recipe)
self.__vscode_settings_clangd(settings_dict, modified_recipe)
+ self.__vscode_settings_format(settings_dict, modified_recipe)
settings_file = 'settings.json'
IdeBase.update_json_file(
--
2.55.0
next prev parent reply other threads:[~2026-09-09 21:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 21:53 [PATCH 00/15] devtool ide-sdk: support booting from NFS, VSCode clangd AdrianF
2026-09-09 21:53 ` [PATCH 01/15] devtool: deploy: split ssh deployment into a separate function AdrianF
2026-09-09 21:53 ` [PATCH 02/15] devtool: deploy: allow deploying directly into a local rootfs directory AdrianF
2026-09-09 21:53 ` [PATCH 03/15] oe-selftest: devtool deploy-target: test deploying into a local rootfs path AdrianF
2026-09-09 21:53 ` [PATCH 04/15] devtool: ide-sdk: support NFS rootfs AdrianF
2026-09-09 21:53 ` [PATCH 05/15] oe-selftest: devtool ide-sdk: test NFS debug rootfs AdrianF
2026-09-09 21:53 ` [PATCH 06/15] runqemu-extract-sdk: refactor in Python AdrianF
2026-09-10 17:45 ` [OE-core] " Richard Purdie
2026-09-09 21:53 ` [PATCH 07/15] devtool: ide-sdk: reuse pseudo_rootfs_utils for SDK rootfs extraction AdrianF
2026-09-09 21:53 ` [PATCH 08/15] cpp-example: update formatting and code style AdrianF
2026-09-09 21:53 ` [PATCH 09/15] cpp-example: fix clang-tidy warnings AdrianF
2026-09-09 21:53 ` [PATCH 10/15] devtool: ide-sdk: add clangd support for VSCode IntelliSense AdrianF
2026-09-09 21:53 ` [PATCH 11/15] devtool: ide-sdk: support clangd for non-clang toolchain recipes AdrianF
2026-09-09 21:53 ` AdrianF [this message]
2026-09-09 21:53 ` [PATCH 13/15] devtool: ide-sdk: support LLDB ATTACH mode AdrianF
2026-09-09 21:53 ` [PATCH 14/15] devtool: ide-sdk: pin BBPATH in generated do_install script AdrianF
2026-09-09 21:53 ` [PATCH 15/15] buildstats: close proc/disk log files via weakref.finalize safety net AdrianF
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260909215337.89106-13-adrian.freihofer@siemens.com \
--to=adrian.freihofer@siemens.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.