I like YouCompleteMe, but it apparently has a major drawback for C/C++, which is no static analysis. Moreover, it disables Syntastic, which does provide static analysis, and they are generally incompatible. My goal is to be able to configure C++ checkers through clang-tidy, which is supported through clangd, the YCM backend I'm using.

So far, I've found that YCM has a --clang-tidy install option, but it's used by developers only, and people always seem to say "it's not useful for normal users". It's not clear to me what it's doing.

Still, others have said that YCM can do everything Syntastic does, which is why you don't need both. How can that be true if you can't use checkers? So I thought maybe it was already available, but my project's .clang-tidy file is ignored, so maybe not.

Finally, I wondered if I could pass arguments directly to clangd, which has a --clang-tidy argument to enable those checks. I haven't found something like that yet, and I'm not sure if YCM will support the output even if it does work. Here's something close but I haven't checked yet.

So, how can I use clang-tidy with YouCompleteMe, or at least, how can I use c++ checkers like CppCoreGuidelines with it?

  • Update: I realized that while Syntastic and YCM conflict, I can still use a linter like ALE without as much interference. This works out of the box, but I don't know how well. Still testing. Jul 29, 2021 at 16:47
  • if the solution you found is satisfying don't hesitate to post it as an answer.
    – statox
    Jul 30, 2021 at 10:50

2 Answers 2


According to the clangd getting started documentation in your original post, you're able to modify the arguments to clangd using:

let g:ycm_clangd_args = ['']

From clangd --help:

<... snip>
clangd feature options:

  --all-scopes-completion         - If set to true, code completion will include index symbols that are not defined in the scopes (e.g. namespaces) visible from the code completion point. Such completions can insert scope qualifiers
  --background-index              - Index project code in the background and persist index on disk.
  --clang-tidy                    - Enable clang-tidy diagnostics
<snip ...>

So you can update your ~/.vimrc to include the line:

let g:ycm_clangd_args = ['--clang-tidy']

along with any other arguments to pass to the clangd executable, and when you place a .clang-tidy file in your project root, clangd should incorporate all of the clang-tidy suggestions.

I've only tested this briefly but it seems to be working to me.

NOTE: I also went through the other steps suggested in the linked documentation, including specifying my system installed clangd executable as the one to use rather than the one that ships with YCM. It's not clear to me at the moment whether this is required (though I can't see why it would be)


Answering my own question, the best approach has been to use ALE as a linter along with YCM for autocomplete. I wasn't able to find any more information about using linters with YCM, but with ALE you can employ dozens of checkers in different languages (not just C/C++ like YCM), and the installation worked right out of the box. I haven't had any issues in the last few days I've been using it, configuration is simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.