Skip to content

clangd config for ide integration#37

Open
relzp wants to merge 8 commits intomainfrom
hallett/clangd-config
Open

clangd config for ide integration#37
relzp wants to merge 8 commits intomainfrom
hallett/clangd-config

Conversation

@relzp
Copy link
Contributor

@relzp relzp commented Jan 30, 2026

adds files (compile_flags.txt, .clangd) to configure clangd so that the clangd extension can be used in vscode (or anywhere with clangd support) for code highlighting, code completion, etc.
the config also does the following:

  1. suppresses warnings about unused includes, since:
  • we use includes like module.c -> module.h, where module.h includes the symbols that both the header and source need
  • the stm32 library also uses includes like this, for example we define the modules we want and then include stm32h7xx_hal.h, instead of each individual module (e.g stm32h7xx_hal_spi.h)
  1. suppresses errors from the stm32 libraries (under Drivers/)

currently, it uses the default compiler installed on the user's machine, not the target architecture (arm) compiler, for simplicity and so that each user doesn't have to install the cross-compiler

Copy link
Contributor

@Claegtun Claegtun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these files only affect vscode, not the actual compiling of the binary in CubeIDE?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file affect or influence the parent .clang files, i.e. .clang-format and .clang-tidy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, .clangd is only used by clangd, .clang-format is only used by clang-format, .clang-tidy is only used by clang-tidy, and they don't have any connection to each other

clang-format formats files, clang-tidy lints code to detect errors, whereas clangd is a language server used to integrate code into an IDE with code completion, compile errors, etc.

I'm not sure if there's any reason to use clang-tidy if using clangd, clangd seems to provide a superset of clang-tidy's functionality, as well as proper IDE integration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction, the vscode clangd extension actually embeds both: clang-format (reads .clang-format) providing formatting, and clang-tidy (reads .clang-tidy) which

provides extra hints about code problems: bug-prone patterns, performance traps, and style issues.

@relzp
Copy link
Contributor Author

relzp commented Feb 13, 2026

Do these files only affect vscode, not the actual compiling of the binary in CubeIDE?

Yeah, both .clangd and compile_flags.txt are files specific to clangd (the language server, not to be confused with clang, the compiler)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants