forked from qt-creator/qt-creator
Python: support python 3 mime type in language client
Change-Id: I9319442aecc61e854aaeb0778b959086a70d431b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -49,6 +49,7 @@ const char PYLS_SETTINGS_ID[] = "Python.PyLSSettingsID";
|
|||||||
* MIME type
|
* MIME type
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
const char C_PY_MIMETYPE[] = "text/x-python";
|
const char C_PY_MIMETYPE[] = "text/x-python";
|
||||||
|
const char C_PY3_MIMETYPE[] = "text/x-python3";
|
||||||
const char C_PY_MIME_ICON[] = "text-x-python";
|
const char C_PY_MIME_ICON[] = "text-x-python";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
@@ -389,7 +389,8 @@ PyLSSettings::PyLSSettings()
|
|||||||
m_settingsTypeId = Constants::PYLS_SETTINGS_ID;
|
m_settingsTypeId = Constants::PYLS_SETTINGS_ID;
|
||||||
m_name = "Python Language Server";
|
m_name = "Python Language Server";
|
||||||
m_startBehavior = RequiresFile;
|
m_startBehavior = RequiresFile;
|
||||||
m_languageFilter.mimeTypes = QStringList(Constants::C_PY_MIMETYPE);
|
m_languageFilter.mimeTypes = QStringList()
|
||||||
|
<< Constants::C_PY_MIMETYPE << Constants::C_PY3_MIMETYPE;
|
||||||
m_arguments = "-m pylsp";
|
m_arguments = "-m pylsp";
|
||||||
const QJsonDocument config(defaultConfiguration());
|
const QJsonDocument config(defaultConfiguration());
|
||||||
m_configuration = QString::fromUtf8(config.toJson());
|
m_configuration = QString::fromUtf8(config.toJson());
|
||||||
@@ -416,6 +417,8 @@ void PyLSSettings::fromMap(const QVariantMap &map)
|
|||||||
const QJsonDocument config(defaultConfiguration());
|
const QJsonDocument config(defaultConfiguration());
|
||||||
m_configuration = QString::fromUtf8(config.toJson());
|
m_configuration = QString::fromUtf8(config.toJson());
|
||||||
}
|
}
|
||||||
|
m_languageFilter.mimeTypes = QStringList()
|
||||||
|
<< Constants::C_PY_MIMETYPE << Constants::C_PY3_MIMETYPE;
|
||||||
setInterpreter(map[interpreterKey].toString());
|
setInterpreter(map[interpreterKey].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,7 +643,8 @@ static Client *registerLanguageServer(const FilePath &python)
|
|||||||
auto *settings = new StdIOSettings();
|
auto *settings = new StdIOSettings();
|
||||||
settings->m_executable = python;
|
settings->m_executable = python;
|
||||||
settings->m_arguments = "-m pylsp";
|
settings->m_arguments = "-m pylsp";
|
||||||
settings->m_languageFilter.mimeTypes = QStringList(Constants::C_PY_MIMETYPE);
|
settings->m_languageFilter.mimeTypes = QStringList() << Constants::C_PY_MIMETYPE
|
||||||
|
<< Constants::C_PY3_MIMETYPE;
|
||||||
}
|
}
|
||||||
settings->m_name = PyLSConfigureAssistant::tr("Python Language Server (%1)")
|
settings->m_name = PyLSConfigureAssistant::tr("Python Language Server (%1)")
|
||||||
.arg(pythonName(python));
|
.arg(pythonName(python));
|
||||||
|
@@ -236,7 +236,8 @@ void PythonRunConfiguration::currentInterpreterChanged()
|
|||||||
|
|
||||||
for (FilePath &file : project()->files(Project::AllFiles)) {
|
for (FilePath &file : project()->files(Project::AllFiles)) {
|
||||||
if (auto document = TextEditor::TextDocument::textDocumentForFilePath(file)) {
|
if (auto document = TextEditor::TextDocument::textDocumentForFilePath(file)) {
|
||||||
if (document->mimeType() == Constants::C_PY_MIMETYPE) {
|
if (document->mimeType() == Constants::C_PY_MIMETYPE
|
||||||
|
|| document->mimeType() == Constants::C_PY3_MIMETYPE) {
|
||||||
PyLSConfigureAssistant::openDocumentWithPython(python, document);
|
PyLSConfigureAssistant::openDocumentWithPython(python, document);
|
||||||
PySideInstaller::checkPySideInstallation(python, document);
|
PySideInstaller::checkPySideInstallation(python, document);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user