Commit d2a1a6e4 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

LSP: Allow disabling signature help

Signature help in C++ with function template and template arguments
leads to a very terrible UI with huge multiple completion boxes. The least we can
do for now is to provide a config option to disable it.
parent 85b17a3c
......@@ -140,6 +140,7 @@ class LSPClientCompletionImpl : public LSPClientCompletion
QSharedPointer<LSPClientServerManager> m_manager;
QSharedPointer<LSPClientServer> m_server;
LSPClientPlugin *m_plugin;
bool m_selectedDocumentation = false;
QVector<QChar> m_triggersCompletion;
......@@ -150,10 +151,11 @@ class LSPClientCompletionImpl : public LSPClientCompletion
LSPClientServer::RequestHandle m_handle, m_handleSig;
public:
LSPClientCompletionImpl(QSharedPointer<LSPClientServerManager> manager)
LSPClientCompletionImpl(QSharedPointer<LSPClientServerManager> manager, LSPClientPlugin *plugin)
: LSPClientCompletion(nullptr)
, m_manager(std::move(manager))
, m_server(nullptr)
, m_plugin(plugin)
{
}
......@@ -301,7 +303,9 @@ public:
if (!m_triggerSignature) {
m_handle = m_server->documentCompletion(document->url(), {cursor.line(), cursor.column()}, this, handler);
}
m_handleSig = m_server->signatureHelp(document->url(), {cursor.line(), cursor.column()}, this, sigHandler);
if (m_plugin->m_signatureHelp) {
m_handleSig = m_server->signatureHelp(document->url(), {cursor.line(), cursor.column()}, this, sigHandler);
}
}
setRowCount(m_matches.size());
endResetModel();
......@@ -340,9 +344,9 @@ public:
}
};
LSPClientCompletion *LSPClientCompletion::new_(QSharedPointer<LSPClientServerManager> manager)
LSPClientCompletion *LSPClientCompletion::new_(QSharedPointer<LSPClientServerManager> manager, LSPClientPlugin *plugin)
{
return new LSPClientCompletionImpl(std::move(manager));
return new LSPClientCompletionImpl(std::move(manager), plugin);
}
#include "lspclientcompletion.moc"
......@@ -14,6 +14,8 @@
#include <KTextEditor/CodeCompletionModel>
#include <KTextEditor/CodeCompletionModelControllerInterface>
class LSPClientPlugin;
class LSPClientCompletion : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface
{
Q_OBJECT
......@@ -22,7 +24,7 @@ class LSPClientCompletion : public KTextEditor::CodeCompletionModel, public KTex
public:
// implementation factory method
static LSPClientCompletion *new_(QSharedPointer<LSPClientServerManager> manager);
static LSPClientCompletion *new_(QSharedPointer<LSPClientServerManager> manager, LSPClientPlugin *plugin);
LSPClientCompletion(QObject *parent)
: KTextEditor::CodeCompletionModel(parent)
......
......@@ -71,7 +71,8 @@ LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugi
ui->chkOnTypeFormatting,
ui->chkIncrementalSync,
ui->chkSemanticHighlighting,
ui->chkAutoHover}) {
ui->chkAutoHover,
ui->chkSignatureHelp}) {
connect(cb, &QCheckBox::toggled, this, &LSPClientConfigPage::changed);
}
auto ch = [this](int) {
......@@ -146,6 +147,7 @@ void LSPClientConfigPage::apply()
m_plugin->m_onTypeFormatting = ui->chkOnTypeFormatting->isChecked();
m_plugin->m_incrementalSync = ui->chkIncrementalSync->isChecked();
m_plugin->m_semanticHighlighting = ui->chkSemanticHighlighting->isChecked();
m_plugin->m_signatureHelp = ui->chkSignatureHelp->isChecked();
m_plugin->m_messages = ui->chkMessages->isChecked();
m_plugin->m_messagesAutoSwitch = ui->comboMessagesSwitch->currentIndex();
......@@ -184,6 +186,7 @@ void LSPClientConfigPage::reset()
ui->chkOnTypeFormatting->setChecked(m_plugin->m_onTypeFormatting);
ui->chkIncrementalSync->setChecked(m_plugin->m_incrementalSync);
ui->chkSemanticHighlighting->setChecked(m_plugin->m_semanticHighlighting);
ui->chkSignatureHelp->setChecked(m_plugin->m_signatureHelp);
ui->chkMessages->setChecked(m_plugin->m_messages);
ui->comboMessagesSwitch->setCurrentIndex(m_plugin->m_messagesAutoSwitch);
......
......@@ -38,6 +38,7 @@ static const QString CONFIG_MESSAGES{QStringLiteral("Messages")};
static const QString CONFIG_MESSAGES_AUTO_SWITCH{QStringLiteral("MessagesAutoSwitch")};
static const QString CONFIG_SERVER_CONFIG{QStringLiteral("ServerConfiguration")};
static const QString CONFIG_SEMANTIC_HIGHLIGHTING{QStringLiteral("SemanticHighlighting")};
static const QString CONFIG_SIGNATURE_HELP{QStringLiteral("SignatureHelp")};
K_PLUGIN_FACTORY_WITH_JSON(LSPClientPluginFactory, "lspclientplugin.json", registerPlugin<LSPClientPlugin>();)
......@@ -107,6 +108,7 @@ void LSPClientPlugin::readConfig()
m_messagesAutoSwitch = config.readEntry(CONFIG_MESSAGES_AUTO_SWITCH, 1);
m_configPath = config.readEntry(CONFIG_SERVER_CONFIG, QUrl());
m_semanticHighlighting = config.readEntry(CONFIG_SEMANTIC_HIGHLIGHTING, false);
m_signatureHelp = config.readEntry(CONFIG_SIGNATURE_HELP, true);
emit update();
}
......@@ -132,6 +134,7 @@ void LSPClientPlugin::writeConfig() const
config.writeEntry(CONFIG_MESSAGES_AUTO_SWITCH, m_messagesAutoSwitch);
config.writeEntry(CONFIG_SERVER_CONFIG, m_configPath);
config.writeEntry(CONFIG_SEMANTIC_HIGHLIGHTING, m_semanticHighlighting);
config.writeEntry(CONFIG_SIGNATURE_HELP, m_signatureHelp);
emit update();
}
......
......@@ -55,6 +55,7 @@ public:
bool m_incrementalSync = false;
QUrl m_configPath;
bool m_semanticHighlighting = false;
bool m_signatureHelp = true;
// debug mode?
bool m_debugMode = false;
......
......@@ -417,7 +417,7 @@ public:
, m_mainWindow(mainWin)
, m_client(client)
, m_serverManager(std::move(serverManager))
, m_completion(LSPClientCompletion::new_(m_serverManager))
, m_completion(LSPClientCompletion::new_(m_serverManager, plugin))
, m_hover(LSPClientHover::new_(m_serverManager))
, m_forwardHover(new ForwardingTextHintProvider(this))
, m_symbolView(LSPClientSymbolView::new_(plugin, mainWin, m_serverManager))
......
......@@ -83,6 +83,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSignatureHelp">
<property name="text">
<string>Enable signature help with autocomplete</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......
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