Closed kotborealis closed 2 months ago
Does it use default cpptools formatting? Or does it use LSP formatting capabilities?
It uses LSP formatting capabilities. For the "pressing enter will cause clangd to format the old line" part in particular, it uses the on-type formatting request. The regular formatting request that you linked to is used when you invoke the "Format Document" command, or on file save if you have format-on-save enabled.
To clarify, I'm searching for a way to setup custom binary for formatting, to format code using known version of clang-format. Is specifying
clangd
binary enough?
The relevant vscode setting is "editor.defaultFormatter"
. If you have the vscode-clangd plugin installed, there should be an option to set this to "llvm-vs-code-extensions.vscode-clangd"
, which will use clangd for formatting.
You can also install a dedicated clang-format plugin like https://marketplace.visualstudio.com/items?itemName=xaver.clang-format and set "editor.defaultFormatter"
to that. You can do this if you want to use a particular version of clang-format, and a different version of clangd (for non-formatting features) at the same time.
Thank you for the detailed answer! I'll close this now.
Definitely not a bug, but I wanted to ask something and could not find a better place to do so.
In readme there's info about clang-format:
However, I could not find anything related in sources. Is this provided by some other parts of vscode? Does it use default cpptools formatting? Or does it use LSP formatting capabilities?
To clarify, I'm searching for a way to setup custom binary for formatting, to format code using known version of clang-format. Is specifying
clangd
binary enough?