diff --git a/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc b/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc index e6ac7282b2e..a95639febf4 100644 --- a/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc +++ b/doc/qtcreator/src/editors/creator-only/creator-clang-codemodel.qdoc @@ -143,14 +143,21 @@ \uicontrol Clangd > \uicontrol {Use clangd}. \image qtcreator-options-clangd.png "clangd preferences" \li In \uicontrol {Path to executable}, enter the path to clangd - version 13, or later. + version 14, or later. \li For more accurate results during global symbol searches, select \uicontrol {Enable background indexing}. However, this increases the - CPU load the first time you open the project. - \li Select \uicontrol {Insert header files on completion} to allow - clangd to insert header files as part of symbol completion. + CPU load the first time you open the project. If clangd background + indexing is disabled, \QC falls back to a faster, but less accurate + built-in indexer. \li By default, clangd attempts to use all unused cores. You can set a fixed number of cores to use in \uicontrol {Worker thread count}. + Background indexing also uses this many worker threads. + \li Select \uicontrol {Insert header files on completion} to allow + clangd to insert header files as part of symbol completion. + \li Set the number of \uicontrol {Completion results} if you regularly + miss important results during code completion. Set it to 0 to remove + the limit on the number of completion results. Setting this to 0 or a + very high number can make code completion slow. \li In \uicontrol {Document update threshold}, specify the amount of time \QC waits before sending document changes to the server. If the document changes again while waiting, this timeout is reset. diff --git a/src/plugins/cppeditor/cppcodemodelsettingspage.cpp b/src/plugins/cppeditor/cppcodemodelsettingspage.cpp index cd7718cef6b..7aa6ecca2ae 100644 --- a/src/plugins/cppeditor/cppcodemodelsettingspage.cpp +++ b/src/plugins/cppeditor/cppcodemodelsettingspage.cpp @@ -169,45 +169,62 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD : d(new Private) { const ClangdSettings settings(settingsData); + const QString indexingToolTip = tr( + "If background indexing is enabled, global symbol searches will yield\n" + "more accurate results, at the cost of additional CPU load when\n" + "the project is first opened.\n" + "The indexing result is persisted in the project's build directory.\n" + "\n" + "If you disable background indexing, a faster, but less accurate,\n" + "built-in indexer is used instead."); + const QString workerThreadsToolTip = tr( + "Number of worker threads used by clangd. Background indexing also uses this many " + "worker threads."); + const QString autoIncludeToolTip = tr( + "Controls whether clangd may insert header files as part of symbol completion."); + const QString documentUpdateToolTip = tr( + "Defines the amount of time Qt Creator waits before sending document changes to the " + "server.\n" + "If the document changes again while waiting, this timeout resets."); + const QString sizeThresholdToolTip = tr( + "Files greater than this will not be opened as documents in clangd.\n" + "The built-in code model will handle highlighting, completion and so on."); + const QString completionResultToolTip = tr( + "The maximum number of completion results returned by clangd."); + d->useClangdCheckBox.setText(tr("Use clangd")); d->useClangdCheckBox.setChecked(settings.useClangd()); d->clangdChooser.setExpectedKind(Utils::PathChooser::ExistingCommand); d->clangdChooser.setFilePath(settings.clangdFilePath()); d->clangdChooser.setEnabled(d->useClangdCheckBox.isChecked()); d->indexingCheckBox.setChecked(settings.indexingEnabled()); - d->indexingCheckBox.setToolTip(tr( - "If background indexing is enabled, global symbol searches will yield\n" - "more accurate results, at the cost of additional CPU load when\n" - "the project is first opened.")); + d->indexingCheckBox.setToolTip(indexingToolTip); d->autoIncludeHeadersCheckBox.setChecked(settings.autoIncludeHeaders()); - d->autoIncludeHeadersCheckBox.setToolTip(tr( - "Controls whether clangd may insert header files as part of symbol completion.")); + d->autoIncludeHeadersCheckBox.setToolTip(autoIncludeToolTip); d->threadLimitSpinBox.setValue(settings.workerThreadLimit()); d->threadLimitSpinBox.setSpecialValueText("Automatic"); + d->threadLimitSpinBox.setToolTip(workerThreadsToolTip); d->documentUpdateThreshold.setMinimum(50); d->documentUpdateThreshold.setMaximum(10000); d->documentUpdateThreshold.setValue(settings.documentUpdateThreshold()); d->documentUpdateThreshold.setSingleStep(100); d->documentUpdateThreshold.setSuffix(" ms"); - d->documentUpdateThreshold.setToolTip( - tr("Defines the amount of time Qt Creator waits before sending document changes to the " - "server.\n" - "If the document changes again while waiting, this timeout resets.\n")); + d->documentUpdateThreshold.setToolTip(documentUpdateToolTip); d->sizeThresholdCheckBox.setText(tr("Ignore files greater than")); d->sizeThresholdCheckBox.setChecked(settings.sizeThresholdEnabled()); + d->sizeThresholdCheckBox.setToolTip(sizeThresholdToolTip); d->sizeThresholdSpinBox.setMinimum(1); d->sizeThresholdSpinBox.setMaximum(std::numeric_limits::max()); d->sizeThresholdSpinBox.setSuffix(" KB"); d->sizeThresholdSpinBox.setValue(settings.sizeThresholdInKb()); - d->sizeThresholdSpinBox.setToolTip(tr( - "Files greater than this will not be opened as documents in clangd.\n" - "The built-in code model will handle highlighting, completion and so on.")); + d->sizeThresholdSpinBox.setToolTip(sizeThresholdToolTip); const auto completionResultsLabel = new QLabel(tr("Completion results:")); + completionResultsLabel->setToolTip(completionResultToolTip); d->completionResults.setMinimum(0); d->completionResults.setMaximum(std::numeric_limits::max()); d->completionResults.setValue(settings.completionResults()); - d->completionResults.setToolTip(tr("The maximum number of completion results returned by clangd")); + d->completionResults.setToolTip(completionResultToolTip); d->completionResults.setSpecialValueText(tr("No limit")); const auto layout = new QVBoxLayout(this); @@ -218,29 +235,34 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD formLayout->addRow(chooserLabel, &d->clangdChooser); formLayout->addRow(QString(), &d->versionWarningLabel); const auto indexingLabel = new QLabel(tr("Enable background indexing:")); + indexingLabel->setToolTip(indexingToolTip); formLayout->addRow(indexingLabel, &d->indexingCheckBox); - const auto autoIncludeHeadersLabel = new QLabel(tr("Insert header files on completion:")); - formLayout->addRow(autoIncludeHeadersLabel, &d->autoIncludeHeadersCheckBox); const auto threadLimitLayout = new QHBoxLayout; threadLimitLayout->addWidget(&d->threadLimitSpinBox); threadLimitLayout->addStretch(1); const auto threadLimitLabel = new QLabel(tr("Worker thread count:")); + threadLimitLabel->setToolTip(workerThreadsToolTip); formLayout->addRow(threadLimitLabel, threadLimitLayout); - const auto documentUpdateThresholdLayout = new QHBoxLayout; - documentUpdateThresholdLayout->addWidget(&d->documentUpdateThreshold); - documentUpdateThresholdLayout->addStretch(1); - const auto documentUpdateThresholdLabel = new QLabel(tr("Document update threshold:")); - formLayout->addRow(documentUpdateThresholdLabel, documentUpdateThresholdLayout); + const auto autoIncludeHeadersLabel = new QLabel(tr("Insert header files on completion:")); + autoIncludeHeadersLabel->setToolTip(autoIncludeToolTip); + formLayout->addRow(autoIncludeHeadersLabel, &d->autoIncludeHeadersCheckBox); const auto limitResultsLayout = new QHBoxLayout; limitResultsLayout->addWidget(&d->completionResults); limitResultsLayout->addStretch(1); formLayout->addRow(completionResultsLabel, limitResultsLayout); + const auto documentUpdateThresholdLayout = new QHBoxLayout; + documentUpdateThresholdLayout->addWidget(&d->documentUpdateThreshold); + documentUpdateThresholdLayout->addStretch(1); + const auto documentUpdateThresholdLabel = new QLabel(tr("Document update threshold:")); + documentUpdateThresholdLabel->setToolTip(documentUpdateToolTip); + formLayout->addRow(documentUpdateThresholdLabel, documentUpdateThresholdLayout); const auto sizeThresholdLayout = new QHBoxLayout; sizeThresholdLayout->addWidget(&d->sizeThresholdSpinBox); sizeThresholdLayout->addStretch(1); formLayout->addRow(&d->sizeThresholdCheckBox, sizeThresholdLayout); + d->configSelectionWidget = new ClangDiagnosticConfigsSelectionWidget(formLayout); d->configSelectionWidget->refresh( diagnosticConfigsModel(settings.customDiagnosticConfigs()),