[clangd] Add option to use dirty file contents when building preambles.
authorNathan James <n.james93@hotmail.co.uk>
Mon, 17 Jan 2022 10:55:35 +0000 (10:55 +0000)
committerNathan James <n.james93@hotmail.co.uk>
Mon, 17 Jan 2022 10:55:35 +0000 (10:55 +0000)
commit8b88ff08038c5525bdb5d22b050550ca3b34ad77
tree1788e76ca9cfb7db7922d109c0e9bdd131304b20
parentca2ac2bb14624257d9bc0a53919dbbc5f447c7fc
[clangd] Add option to use dirty file contents when building preambles.

Adds a option `use-dirty-preambles` to enable using unsaved in editor contents when building pre-ambles.
This enables a more seamless user experience when switching between header and implementation files and forgetting to save inbetween.
It's also in line with the LSP spec that states open files in the editor should be used instead of on the contents on disk - https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/
For now the option is defaulted to off and hidden, Though I have a feeling it should be moved into the `.clangd` config and possibly defaulted to true.

Addresses https://github.com/clangd/clangd/issues/488

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D95046
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/tool/ClangdMain.cpp