Skip to content

Clarify custom clang_format_style/clang_format_fallbackStyle block must be a string, or also support JSON object syntax #11092

Description

Environment

  • OS and Version: Windows 11 22H2 (build 22621.1702)
  • VS Code Version: 1.79.1
  • C/C++ Extension Version: v1.15.14

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

  1. Go to the JSON settings
  2. Add the following key:
"C_Cpp.clang_format_fallbackStyle": {
    "BasedOnStyle": "Google",
    "IndentWidth": 4,
    "ColumnLimit": 100,
},
  1. The following warning appears (Incorrect type. Expected string):
    image

Expected behavior:
No warning is issued and intellisense is provided as this is a valid setting parameter.

Configuration and Logs

Attached

Other Extensions

No response

Additional context

No response

Activity

  1. jmigual commented on Jun 14, 2023

    @jmigual
    Author
  2. Colengms commented on Jun 14, 2023

    @Colengms
    Contributor

    Hi Joan Marcè i Igual (@jmigual) . The clang_format_style and clang_format_fallbackStyle are string values passed verbatim to the clang-format command line. The syntax is JSON-like, but not intended to be specified in JSON in VS Code settings. The setting description could be more clear about this. But I believe this will work correctly for you, if you specify the block as a string. (I suspect you would not want to quote the field values, in that case).

    i.e.:

        "C_Cpp.clang_format_style": "{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }"
    

    We can use this issue to clarify this in the documentation, or potentially to track adding support for JSON object syntax.

  3. changed the title [-]C_Cpp.clang_format_fallbackStyle "incorrect type"[/-] [+]Clarify custom `clang_format_style`/`clang_format_fallbackStyle` block must be a string, or also support JSON object syntax[/+] on Jun 14, 2023
  4. jmigual commented on Jun 15, 2023

    @jmigual
    Author

    Ah I see! Thank you for the clarification. Indeed adding some documentation would be a good addition. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions