Fallback arguments

As far as I can tell, there doesn't seem to be a method to pass
default arguments for clangd to use when there is no compilation
database found or when no suitable entry for a given file can be found
in the database.

This is a bit inconvenient when writing short throw-away programs
(i.e. that don't require a Makefile or CMakeLists), especially since
the default C++ standard used is C++14, which leads to warnings about
new syntax. I was wondering how difficult it would be to support
passing some default arguments when clangd is started, e.g.:
    clangd -- -Wall -Wextra -Wpedantic -std=c++17

One issue with this is that it would possibly cause problems, since
when a C file was passed, it would see a flag "-std=c++17". However,
one solution could be to use the "-x" flag to set language specific
    clangd -- -Wall -x c -std=gnu99 -x c++ -std=c++17

That would lead to C files using the flags "-Wall -std=gnu99", while
C++ files would use the flags "-Wall -std=c++17". (Note that before
the first "-x" flag, all flags apply to every language).

Would this feature be feasible to add?

For simple projects, you can create a file “compile_flags.txt” in the project root, with one arg on each line.


clangd will parse files with the command “clang $FLAGS $FILE”.
This database isn’t enumerable though, so you won’t get background indexing.

Does this help?

Other approaches are also possible, but not implemented, happy to discuss