Commit f4695ae7 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: extend server properties

parent 1c1a7500
......@@ -741,6 +741,8 @@ class LSPClientServer::LSPClientServerPrivate
QStringList m_server;
// workspace root to pass along
QUrl m_root;
// language id
QString m_langId;
// user provided init
QJsonValue m_init;
// server process
......@@ -760,10 +762,11 @@ class LSPClientServer::LSPClientServerPrivate
QVector<int> m_requests {MAX_REQUESTS + 1};
public:
LSPClientServerPrivate(LSPClientServer *_q, const QStringList &server, const QUrl &root, const QJsonValue &init)
LSPClientServerPrivate(LSPClientServer *_q, const QStringList &server, const QUrl &root, const QString &langId, const QJsonValue &init)
: q(_q)
, m_server(server)
, m_root(root)
, m_langId(langId)
, m_init(init)
{
// setup async reading
......@@ -781,6 +784,16 @@ public:
return m_server;
}
const QUrl &root() const
{
return m_root;
}
const QString &langId() const
{
return m_langId;
}
State state()
{
return m_state;
......@@ -1257,8 +1270,8 @@ template<typename ReplyType> static GenericReplyHandler make_handler(const Reply
};
}
LSPClientServer::LSPClientServer(const QStringList &server, const QUrl &root, const QJsonValue &init)
: d(new LSPClientServerPrivate(this, server, root, init))
LSPClientServer::LSPClientServer(const QStringList &server, const QUrl &root, const QString &langId, const QJsonValue &init)
: d(new LSPClientServerPrivate(this, server, root, langId, init))
{
}
......@@ -1272,6 +1285,16 @@ const QStringList &LSPClientServer::cmdline() const
return d->cmdline();
}
const QUrl &LSPClientServer::root() const
{
return d->root();
}
const QString &LSPClientServer::langId() const
{
return d->langId();
}
LSPClientServer::State LSPClientServer::state() const
{
return d->state();
......
......@@ -98,7 +98,7 @@ public:
}
};
LSPClientServer(const QStringList &server, const QUrl &root, const QJsonValue &init = QJsonValue());
LSPClientServer(const QStringList &server, const QUrl &root, const QString &langId = QString(), const QJsonValue &init = QJsonValue());
~LSPClientServer() override;
// server management
......@@ -111,6 +111,8 @@ public:
// properties
const QStringList &cmdline() const;
const QUrl &root() const;
const QString &langId() const;
State state() const;
Q_SIGNAL void stateChanged(LSPClientServer *server);
......
......@@ -516,6 +516,8 @@ private:
// locate server config
QJsonValue config;
QSet<QString> used;
// reduce langId
auto realLangId = langId;
while (true) {
qCInfo(LSPCLIENT) << "language id " << langId;
used << langId;
......@@ -595,7 +597,7 @@ private:
}
}
if (cmdline.length() > 0) {
server.reset(new LSPClientServer(cmdline, root, serverConfig.value(QStringLiteral("initializationOptions"))));
server.reset(new LSPClientServer(cmdline, root, realLangId, serverConfig.value(QStringLiteral("initializationOptions"))));
connect(server.data(), &LSPClientServer::stateChanged, this, &self_type::onStateChanged, Qt::UniqueConnection);
if (!server->start(m_plugin)) {
showMessage(i18n("Failed to start server: %1", cmdline.join(QLatin1Char(' '))), KTextEditor::Message::Error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment