Search code examples
neovimclangdneovim-plugin

How to stop clangd from suggesting functions that are not in the included header files


I am using neovim with coc.nvim and coc-clangd, I want the code completion to stop recommending functions that are not in the header files that I have included.screenshot

I have not been able to find anything relevant to my issue, when I google it I only find how to stop auto including files


Solution

  • Creating a .clangd file with the following will help:

    Index:
      StandardLibrary: No
    

    (See https://clangd.llvm.org/config.html#standardlibrary for more details.)

    This will prevent clangd from indexing all standard library headers upfront.

    Note, however, that clangd will still suggest functions from files that are included anywhere in your project (so, if another file in your project includes wchar.h, you will still get completions from wchar.h).

    There isn't currently a mode to only suggest functions from headers included in the current file. You're welcome to file a feature request about that at https://github.com/clangd/clangd/issues.