简体   繁体   中英

Why my clangd in vscode will change my header file's order to alphabetical order when I was fomating doc?

I found my clangd plugin in VSCode will modify *.h file's order to alphabetical order. For example:

before:
-#include "c.h"
-#include "b.h"
-#include "a.h"
after:
+#include "a.h"
+#include "b.h"
+#include "c.h"

And here is my clangd's settins,How do I fix this bug.

"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,

Clangd formats your code using clang-format (or more precisely, the LibFormat library that's also used by clang-format), and respects the configuration found in the .clang-format file in the project's root directory (or a subdirectory).

See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the various formatting options supported by clang-format. The one relevant to your question is SortIncludes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM