Commit 13df45c5 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: add menu action to configure optional completion signature help

parent 2fbb003a
......@@ -139,8 +139,8 @@ class LSPClientCompletionImpl : public LSPClientCompletion
QSharedPointer<LSPClientServerManager> m_manager;
QSharedPointer<LSPClientServer> m_server;
LSPClientPlugin *m_plugin;
bool m_selectedDocumentation = false;
bool m_signatureHelp = true;
QVector<QChar> m_triggersCompletion;
QVector<QChar> m_triggersSignature;
......@@ -150,11 +150,10 @@ class LSPClientCompletionImpl : public LSPClientCompletion
LSPClientServer::RequestHandle m_handle, m_handleSig;
public:
LSPClientCompletionImpl(QSharedPointer<LSPClientServerManager> manager, LSPClientPlugin *plugin)
LSPClientCompletionImpl(QSharedPointer<LSPClientServerManager> manager)
: LSPClientCompletion(nullptr)
, m_manager(std::move(manager))
, m_server(nullptr)
, m_plugin(plugin)
{
}
......@@ -176,6 +175,11 @@ public:
m_selectedDocumentation = s;
}
void setSignatureHelp(bool s) override
{
m_signatureHelp = s;
}
QVariant data(const QModelIndex &index, int role) const override
{
if (!index.isValid() || index.row() >= m_matches.size()) {
......@@ -302,7 +306,7 @@ public:
if (!m_triggerSignature) {
m_handle = m_server->documentCompletion(document->url(), {cursor.line(), cursor.column()}, this, handler);
}
if (m_plugin->m_signatureHelp) {
if (m_signatureHelp) {
m_handleSig = m_server->signatureHelp(document->url(), {cursor.line(), cursor.column()}, this, sigHandler);
}
}
......@@ -360,9 +364,9 @@ public:
}
};
LSPClientCompletion *LSPClientCompletion::new_(QSharedPointer<LSPClientServerManager> manager, LSPClientPlugin *plugin)
LSPClientCompletion *LSPClientCompletion::new_(QSharedPointer<LSPClientServerManager> manager)
{
return new LSPClientCompletionImpl(std::move(manager), plugin);
return new LSPClientCompletionImpl(std::move(manager));
}
#include "lspclientcompletion.moc"
......@@ -13,8 +13,6 @@
#include <KTextEditor/CodeCompletionModel>
#include <KTextEditor/CodeCompletionModelControllerInterface>
class LSPClientPlugin;
class LSPClientCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface
{
Q_OBJECT
......@@ -23,7 +21,7 @@ class LSPClientCompletion : public KTextEditor::CodeCompletionModel, public KTex
public:
// implementation factory method
static LSPClientCompletion *new_(QSharedPointer<LSPClientServerManager> manager, LSPClientPlugin *plugin);
static LSPClientCompletion *new_(QSharedPointer<LSPClientServerManager> manager);
LSPClientCompletion(QObject *parent)
: KTextEditor::CodeCompletionModel(parent)
......@@ -32,6 +30,7 @@ public:
virtual void setServer(QSharedPointer<LSPClientServer> server) = 0;
virtual void setSelectedDocumentation(bool) = 0;
virtual void setSignatureHelp(bool) = 0;
};
#endif
......@@ -316,6 +316,7 @@ class LSPClientActionView : public QObject
QPointer<QAction> m_triggerFormat;
QPointer<QAction> m_triggerRename;
QPointer<QAction> m_complDocOn;
QPointer<QAction> m_signatureHelp;
QPointer<QAction> m_refDeclaration;
QPointer<QAction> m_autoHover;
QPointer<QAction> m_onTypeFormatting;
......@@ -424,7 +425,7 @@ public:
, m_mainWindow(mainWin)
, m_client(client)
, m_serverManager(std::move(serverManager))
, m_completion(LSPClientCompletion::new_(m_serverManager, plugin))
, m_completion(LSPClientCompletion::new_(m_serverManager))
, m_hover(LSPClientHover::new_(m_serverManager))
, m_forwardHover(new ForwardingTextHintProvider(this))
, m_symbolView(LSPClientSymbolView::new_(plugin, mainWin, m_serverManager))
......@@ -462,6 +463,9 @@ public:
m_complDocOn = actionCollection()->addAction(QStringLiteral("lspclient_completion_doc"), this, &self_type::displayOptionChanged);
m_complDocOn->setText(i18n("Show selected completion documentation"));
m_complDocOn->setCheckable(true);
m_signatureHelp = actionCollection()->addAction(QStringLiteral("lspclient_signature_help"), this, &self_type::displayOptionChanged);
m_signatureHelp->setText(i18n("Enable signature help with auto completion"));
m_signatureHelp->setCheckable(true);
m_refDeclaration = actionCollection()->addAction(QStringLiteral("lspclient_references_declaration"), this, &self_type::displayOptionChanged);
m_refDeclaration->setText(i18n("Include declaration in references"));
m_refDeclaration->setCheckable(true);
......@@ -532,6 +536,7 @@ public:
auto moreOptions = new KActionMenu(i18n("More options"), this);
menu->addAction(moreOptions);
moreOptions->addAction(m_complDocOn);
moreOptions->addAction(m_signatureHelp);
moreOptions->addAction(m_refDeclaration);
moreOptions->addAction(m_autoHover);
moreOptions->addAction(m_onTypeFormatting);
......@@ -782,6 +787,9 @@ public:
if (m_complDocOn) {
m_complDocOn->setChecked(m_plugin->m_complDoc);
}
if (m_signatureHelp) {
m_signatureHelp->setChecked(m_plugin->m_signatureHelp);
}
if (m_refDeclaration) {
m_refDeclaration->setChecked(m_plugin->m_refDeclaration);
}
......@@ -2321,6 +2329,7 @@ public:
m_completion->setServer(server);
if (m_complDocOn) {
m_completion->setSelectedDocumentation(m_complDocOn->isChecked());
m_completion->setSignatureHelp(m_signatureHelp->isChecked());
}
updateCompletion(activeView, server.data());
......
......@@ -48,6 +48,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSignatureHelp">
<property name="text">
<string>Enable signature help with auto completion</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRefDeclaration">
<property name="text">
......@@ -90,13 +97,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSignatureHelp">
<property name="text">
<string>Enable signature help with auto completion</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkMessages">
<property name="text">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="lspclient" library="lspclient" version="13" translationDomain="lspclient">
<gui name="lspclient" library="lspclient" version="14" translationDomain="lspclient">
<MenuBar>
<Menu name="LSPClient Menubar">
<text>LSP Client</text>
......@@ -25,7 +25,7 @@
<text>More Options</text>
<DefineGroup name="lspclient_more_options"/>
<Action name="lspclient_completion_doc"/>
<Action name="lspclient_completion_doc"/>
<Action name="lspclient_signature_help"/>
<Action name="lspclient_references_declaration"/>
<Action name="lspclient_auto_hover"/>
<Action name="lspclient_type_formatting"/>
......
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