Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a8aaef8b authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

lspclient: make include declaration in reference configurable

parent aedab445
......@@ -49,7 +49,9 @@ LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugi
outlineBox = new QGroupBox(i18n("General Options"), this);
top = new QVBoxLayout(outlineBox);
m_complDoc = new QCheckBox(i18n("Show selected completion documentation"));
m_refDeclaration = new QCheckBox(i18n("Include declaration in references"));
top->addWidget(m_complDoc);
top->addWidget(m_refDeclaration);
layout->addWidget(outlineBox);
outlineBox = new QGroupBox(i18n("Server Configuration"), this);
......@@ -62,7 +64,7 @@ LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugi
reset();
for (const auto & cb : {m_symbolDetails, m_symbolExpand, m_symbolSort, m_symbolTree, m_complDoc})
for (const auto & cb : {m_symbolDetails, m_symbolExpand, m_symbolSort, m_symbolTree, m_complDoc, m_refDeclaration})
connect(cb, &QCheckBox::toggled, this, &LSPClientConfigPage::changed);
connect(m_configPath, &KUrlRequester::textChanged, this, &LSPClientConfigPage::changed);
connect(m_configPath, &KUrlRequester::urlSelected, this, &LSPClientConfigPage::changed);
......@@ -91,6 +93,7 @@ void LSPClientConfigPage::apply()
m_plugin->m_symbolSort = m_symbolSort->isChecked();
m_plugin->m_complDoc = m_complDoc->isChecked();
m_plugin->m_refDeclaration = m_refDeclaration->isChecked();
m_plugin->m_configPath = m_configPath->url();
......@@ -105,6 +108,7 @@ void LSPClientConfigPage::reset()
m_symbolSort->setChecked(m_plugin->m_symbolSort);
m_complDoc->setChecked(m_plugin->m_complDoc);
m_refDeclaration->setChecked(m_plugin->m_refDeclaration);
m_configPath->setUrl(m_plugin->m_configPath);
}
......
......@@ -53,6 +53,7 @@ class LSPClientConfigPage : public KTextEditor::ConfigPage
QCheckBox* m_symbolTree;
QCheckBox* m_symbolSort;
QCheckBox* m_complDoc;
QCheckBox* m_refDeclaration;
KUrlRequester *m_configPath;
LSPClientPlugin *m_plugin;
......
......@@ -35,6 +35,7 @@ static const QString CONFIG_SYMBOL_TREE { QStringLiteral("SymbolTree") };
static const QString CONFIG_SYMBOL_EXPAND { QStringLiteral("SymbolExpand") };
static const QString CONFIG_SYMBOL_SORT { QStringLiteral("SymbolSort") };
static const QString CONFIG_COMPLETION_DOC { QStringLiteral("CompletionDocumentation") };
static const QString CONFIG_REFERENCES_DECLARATION { QStringLiteral("ReferencesDeclaration") };
static const QString CONFIG_SERVER_CONFIG { QStringLiteral("ServerConfiguration") };
......@@ -77,6 +78,7 @@ void LSPClientPlugin::readConfig()
m_symbolExpand = config.readEntry(CONFIG_SYMBOL_EXPAND, true);
m_symbolSort = config.readEntry(CONFIG_SYMBOL_SORT, false);
m_complDoc = config.readEntry(CONFIG_COMPLETION_DOC, true);
m_refDeclaration = config.readEntry(CONFIG_REFERENCES_DECLARATION, true);
m_configPath = config.readEntry(CONFIG_SERVER_CONFIG, QUrl());
emit update();
......@@ -90,6 +92,7 @@ void LSPClientPlugin::writeConfig() const
config.writeEntry(CONFIG_SYMBOL_EXPAND, m_symbolExpand);
config.writeEntry(CONFIG_SYMBOL_SORT, m_symbolSort);
config.writeEntry(CONFIG_COMPLETION_DOC, m_complDoc);
config.writeEntry(CONFIG_REFERENCES_DECLARATION, m_refDeclaration);
config.writeEntry(CONFIG_SERVER_CONFIG, m_configPath);
emit update();
......
......@@ -49,6 +49,7 @@ class LSPClientPlugin : public KTextEditor::Plugin
bool m_symbolTree;
bool m_symbolSort;
bool m_complDoc;
bool m_refDeclaration;
QUrl m_configPath;
private:
......
......@@ -87,6 +87,7 @@ class LSPClientPluginViewImpl : public QObject, public KXMLGUIClient
QPointer<QAction> m_highlight;
QPointer<QAction> m_hover;
QPointer<QAction> m_complDocOn;
QPointer<QAction> m_refDeclaration;
QPointer<QAction> m_restartServer;
QPointer<QAction> m_restartAll;
......@@ -134,10 +135,13 @@ public:
m_hover = actionCollection()->addAction(QStringLiteral("lspclient_hover"), this, &self_type::hover);
m_hover->setText(i18n("Hover"));
// completion configuration
// general options
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_refDeclaration = actionCollection()->addAction(QStringLiteral("lspclient_references_declaration"), this, &self_type::displayOptionChanged);
m_refDeclaration->setText(i18n("Include declaration in references"));
m_refDeclaration->setCheckable(true);
// server control
m_restartServer = actionCollection()->addAction(QStringLiteral("lspclient_restart_server"), this, &self_type::restartCurrent);
......@@ -155,6 +159,7 @@ public:
menu->addAction(m_hover);
menu->addSeparator();
menu->addAction(m_complDocOn);
menu->addAction(m_refDeclaration);
menu->addSeparator();
menu->addAction(m_restartServer);
menu->addAction(m_restartAll);
......@@ -194,6 +199,8 @@ public:
{
if (m_complDocOn)
m_complDocOn->setChecked(m_plugin->m_complDoc);
if (m_refDeclaration)
m_refDeclaration->setChecked(m_plugin->m_refDeclaration);
displayOptionChanged();
}
......@@ -482,10 +489,10 @@ public:
void findReferences()
{
auto title = i18nc("@title:tab", "References: %1", currentWord());
// TODO declaration configurable ??
auto req = [] (LSPClientServer & server, const QUrl & document, const LSPPosition & pos,
bool decl = m_refDeclaration->isChecked();
auto req = [decl] (LSPClientServer & server, const QUrl & document, const LSPPosition & pos,
const QObject *context, const DocumentDefinitionReplyHandler & h)
{ return server.documentReferences(document, pos, true, context, h); };
{ return server.documentReferences(document, pos, decl, context, h); };
goToLocation(title, req, true);
}
......
......@@ -11,6 +11,7 @@
<Action name="lspclient_hover"/>
<Separator/>
<Action name="lspclient_completion_doc"/>
<Action name="lspclient_references_declaration"/>
<Separator/>
<Action name="lspclient_restart_server"/>
<Action name="lspclient_restart_all"/>
......
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