Change default clangd index path

I mainly use vscode to write C++. I moved from the default plugin to ccls to clangd. Compared to ccls, clangd is much faster but doesn’t have the option to change the cache directory.

I have 32 GBs of ram and to make better use of it, I create a 10GB ramdisk at boot. I used to put my .ccls-cache forlder there but with clangd it’s not possible. My current workaround is to delete the folder, create mnt/ramdisk/project_name/.cache, simlink it to /actual_path_to_project/.cache and then restart the language server. I could more or less automate it but I think it’d be overkill.

Am I missing something? If not, it’d be nice to have that option in a future release.

Unfortunately clangd doesn’t have a way to customize project-specific cache directories, but it will respect $XDG_CACHE_HOME for the non-owned sources (ie.g. STL headers).

That being said, clangd only reads the cache contents once at startups and builds an in-memory index afterwards. so unless you are trying to speed-up that initial warm-up latency, putting .cache directory into a ramdisk vs a normal partition shouldn’t make any difference.

Thank you. I didn’t know the index was being kept in the memory. With ccls, my index sizes went up to ~2 GBs so the ramdisk made more sense. With clangd the sizes are so small, I might as well get rid of it.