Clangd: Add per-project settings

Users might want to use clangd for certain project, but not for others.

Change-Id: Id29ce3349f0acd359cf7c824ece073b147ed2280
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-06-28 14:55:54 +02:00
parent b3c83b79f7
commit fbb804c442
10 changed files with 286 additions and 94 deletions

View File

@@ -416,15 +416,15 @@ public:
: Request("textDocument/symbolInfo", params) {}
};
static BaseClientInterface *clientInterface(const Utils::FilePath &jsonDbDir)
static BaseClientInterface *clientInterface(Project *project, const Utils::FilePath &jsonDbDir)
{
QString indexingOption = "--background-index";
if (!CppTools::ClangdSettings::indexingEnabled())
const CppTools::ClangdSettings settings = CppTools::ClangdProjectSettings(project).settings();
if (!settings.indexingEnabled())
indexingOption += "=0";
Utils::CommandLine cmd{CppTools::ClangdSettings::clangdFilePath(),
{indexingOption, "--limit-results=0"}};
if (CppTools::ClangdSettings::workerThreadLimit() != 0)
cmd.addArg("-j=" + QString::number(CppTools::ClangdSettings::workerThreadLimit()));
Utils::CommandLine cmd{settings.clangdFilePath(), {indexingOption, "--limit-results=0"}};
if (settings.workerThreadLimit() != 0)
cmd.addArg("-j=" + QString::number(settings.workerThreadLimit()));
if (!jsonDbDir.isEmpty())
cmd.addArg("--compile-commands-dir=" + jsonDbDir.toString());
if (clangdLog().isDebugEnabled())
@@ -700,7 +700,7 @@ public:
};
ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
: Client(clientInterface(jsonDbDir)), d(new Private(this))
: Client(clientInterface(project, jsonDbDir)), d(new Private(this))
{
setName(tr("clangd"));
LanguageFilter langFilter;