我在VSCode中发现我的clangd插件会将*.h文件的顺序修改为字母顺序。例如:
before:
-#include "c.h"
-#include "b.h"
-#include "a.h"
after:
+#include "a.h"
+#include "b.h"
+#include "c.h"这是我的响尾蛇,我该如何解决这个问题。
"clangd.onConfigChanged": "restart",
"clangd.arguments": [
"--clang-tidy",
"--clang-tidy-checks=performance-*,bugprone-*",
"--compile-commands-dir=${workspaceFolder}/.vscode/",
"--background-index",
"--completion-style=detailed",
"--enable-config",
"--fallback-style=Mozilla",
"--function-arg-placeholders=false",
"--all-scopes-completion",
"--header-insertion-decorators",
"--header-insertion=iwyu",
"--log=verbose",
"--pch-storage=memory",
"--pretty",
"--ranking-model=decision_forest",
"--cross-file-rename",
"-j=16"
],
"clangd.checkUpdates": false,发布于 2022-08-06 17:57:14
Clangd使用clang格式的(或者更准确地说,也由clang-使用的LibFormat库)格式化代码,并尊重项目根目录(或子目录)中.clang-format文件中的配置。
有关clang-格式支持的各种格式设置选项,请参见https://clang.llvm.org/docs/ClangFormatStyleOptions.html。与你的问题相关的是SortIncludes。
https://stackoverflow.com/questions/73259369
复制相似问题