2022-08-15
Since Kate got LSP support some time ago (thanks to all the developers who made/make this possible, it is a great addition), I've been using it a lot; as you'd expect with any tool, it has some default behaviours that you'd want to disable, and some non-default ones that you want to make use of. Below are some of the config tweaks I've collected over time.
First, there are two ways to change the clangd config options:
~/.config/clangd/config.yaml
text file, which will affect all projects.clangd
in a specific project directory.clangd
file in the current dir and then its parent dir ...etc. So, you can have one .clangd file in the parent dir of all your KDE Frameworks checkouts and it'll affect all of them.
Now the config options:
#include <QString>
or #include <KIO/Stat>
):
Diagnostics: UnusedIncludes: StrictSo while it doesn't work a 100% for KDE code which uses ForwardingHeaders a lot, it is still useful to have, since you can remove some unused includes as you go along. Of course be careful as it could mark something as "unused" while it is actually needed for a different code path, e.g. only needed on FreeBSD or Windows.
--- If: PathMatch: /usr/include/.* Diagnostics: Suppress: "*"
CompileFlags: Add: [-Wno-gnu-zero-variadic-macro-arguments] Remove: [-fdiagnostics-urls=always]For example I usually compile with gcc, and I add the
-fdiagnostics-urls=always
flag, but clang knows nothing about it and keeps complaining in e.g. the LSP diagnostics tab in Kate, so this is one way of removing that noisy warning.
For -Wno-gnu-zero-variadic-macro-arguments
see this post.