forked from qt-creator/qt-creator
LanguageClient: also check for inherited mime types
... when trying to auto setup language servers as well when matching the configured mime types against a document mime type. In particular this fixes showing the auto setup editor info bar for the newly introduced clang format mime type as well as starting the yaml server for those files, since this clang format mime type inherits the yaml mime type. Change-Id: Id3ec64b0a1a128b070eadbcad600b3aaf4e667c3 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
@@ -470,11 +470,14 @@ private:
|
||||
QTimer m_killTimer;
|
||||
};
|
||||
|
||||
constexpr QLatin1StringView YAML_MIME_TYPE{"application/x-yaml"};
|
||||
constexpr QLatin1StringView JSON_MIME_TYPE{"application/json"};
|
||||
|
||||
void autoSetupLanguageServer(TextDocument *document)
|
||||
{
|
||||
const QString mimeType = document->mimeType();
|
||||
if (mimeType == "application/x-yaml" || mimeType == "application/json") {
|
||||
const bool isYaml = mimeType == "application/x-yaml";
|
||||
const auto mimeType = Utils::mimeTypeForName(document->mimeType());
|
||||
const bool isYaml = mimeType.inherits(YAML_MIME_TYPE);
|
||||
if (isYaml || mimeType.inherits(JSON_MIME_TYPE)) {
|
||||
// check whether the user suppressed the info bar
|
||||
const Id infoBarId = isYaml ? installYamlLsInfoBarId : installJsonLsInfoBarId;
|
||||
|
||||
@@ -531,7 +534,7 @@ void autoSetupLanguageServer(TextDocument *document)
|
||||
settings->m_executable = executable;
|
||||
settings->m_arguments = "--stdio";
|
||||
settings->m_name = Tr::tr("%1 Language Server").arg(language);
|
||||
settings->m_languageFilter.mimeTypes = {mimeType};
|
||||
settings->m_languageFilter.mimeTypes = {isYaml ? YAML_MIME_TYPE : JSON_MIME_TYPE};
|
||||
|
||||
LanguageClientSettings::addSettings(settings);
|
||||
LanguageClientManager::applySettings();
|
||||
|
||||
Reference in New Issue
Block a user