Clangd has a feature that can insert header that I need automatically. It works on vscode, but not work on my neovim.
my lsp config for clangd.
lsp.clangd.setup {
capabilities = cmp,
cmd = {
"clangd",
"--background-index",
"-j=12",
"--query-driver=/usr/bin/**/clang-*,/bin/clang,/bin/clang++,/usr/bin/gcc,/usr/bin/g++",
"--clang-tidy",
"--clang-tidy-checks=*",
"--all-scopes-completion",
"--cross-file-rename",
"--completion-style=detailed",
"--header-insertion-decorators",
"--header-insertion=iwyu",
"--pch-storage=memory",
}
}