As of clangd12, clangd can use a compilation database (compile_commands.json) just like clang-tidy. You can avoid hard-coding compilation flags (including language standard) if your build tool supports compilation databases.
A compilation database is an autogenerated file that contains a precise dump of compiler settings. They are used to communicate between various C++ tools.
Example with CMake 3.5+ and default clangd config
Use project source directory or a build/ subdirectory as the binary directory and enable the CMAKE_EXPORT_COMPILE_COMMANDS flag:
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# or cmake -B . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
clangd will now use the same settings as the compiler would.
Search paths
By default, when processing any C/C++ file, clangd searches for a compile_commands.json in the file's directory and all parent directories, and in the build/ subdirectory in each of those directories, as pointed out in this answer.
This behavior can be changed via clangd configuration.