Skip to content

Commit

Permalink
Enable native clipboard provider by default
Browse files Browse the repository at this point in the history
After successfuly loading the shim call GuiClipboard to enable the
native GUI clipboard.

ref #298
  • Loading branch information
equalsraf committed Sep 11, 2020
1 parent 05885ba commit 0ace24a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ void Shell::setAttached(bool attached)

auto req_shim = m_nvim->api0()->vim_command("runtime plugin/nvim_gui_shim.vim");
connect(req_shim, &MsgpackRequest::error, this, &Shell::handleShimError);
connect(req_shim, &MsgpackRequest::finished, this, &Shell::handleShimLoad);

auto gviminit = qgetenv("GVIMINIT");
if (gviminit.isEmpty()) {
auto req_ginit = m_nvim->api0()->vim_command("runtime! ginit.vim");
Expand Down Expand Up @@ -1743,6 +1745,20 @@ void Shell::handleShimError(quint32 msgid, quint64 fun, const QVariant& err)
qDebug() << "GUI shim error " << err;
}

void Shell::handleShimLoad(quint32 msgid, quint64 fun, const QVariant& resp)
{
// Enable native clipboard, if api version 6 is available
auto api6 = m_nvim->api6();
if (api6) {
qDebug() << "Enabling native clipboard";
// FIXME we need a way to disable this behaviour and debug messages
// on the nvim side
QVariantList args;
auto req = api6->nvim_call_function("GuiClipboard", args);
connect(req, &MsgpackRequest::error, this, &Shell::handleShimError);
}
}

void Shell::handleGetBackgroundOption(quint32 msgid, quint64 fun, const QVariant& val)
{
const QString mode{ val.toString() };
Expand Down
1 change: 1 addition & 0 deletions src/gui/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ protected slots:
void updateClientInfo();
void handleGinitError(quint32 msgid, quint64 fun, const QVariant& err);
void handleShimError(quint32 msgid, quint64 fun, const QVariant& err);
void handleShimLoad(quint32 msgid, quint64 fun, const QVariant& resp);
void handleGetBackgroundOption(quint32 msgid, quint64 fun, const QVariant& val);

protected:
Expand Down

0 comments on commit 0ace24a

Please sign in to comment.