Skip to content

Commit

Permalink
Migrated .qnvimrc to qnvim.vim and fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sassanh committed Jun 5, 2019
1 parent c9168b0 commit 739d12b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
--

## 1

### 1.0.0 2019-06-05

- $MYQVIMRC is now a file named `qnvim.vim` in the same directory as $MYVIMRC

--

## 0

### 0.4.0 2019-04-29
Expand Down
2 changes: 1 addition & 1 deletion QNVim.json.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
\"Name\" : \"QNVim\",
\"Version\" : \"0.4.0\",
\"Version\" : \"1.0.0\",
\"CompatVersion\" : \"0.4.0\",
\"Vendor\" : \"Sassan Haradji\",
\"Copyright\" : \"(C) Sassan Haradji\",
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ If you want to update qnvim, you just need to `git pull` in its directory and bu

It's important to run `make clean` before building Qt Creator when it's upgraded, otherwise you'll end up with plugins with mismatching versions. (like this https://github.com/sassanh/qnvim/issues/8#issuecomment-485456543)

# Sample `.qnvimrc`
There's a sample `.qnvimrc` file available in the repo, it provides most of the convenient keyboard shortcuts for building, deplying, running, switching buffers, switching tabs, etc. It'll also help you understand how you can create new keyboard shortcuts using Qt Creator commands.
# `qnvim.vim`

You can put custom vim commands for your QtCreator environment in `qnvim.vim` which is a file in the same directory as `init.vim` (`:help $MYVIMRC`). `$MYQVIMRC` (note the `Q` after `MY`) is set to its path.

## Sample `qnvim.vim`

There's a sample `qnvim.vim` file available in the repo, it provides most of the convenient keyboard shortcuts for building, deplying, running, switching buffers, switching tabs, etc. It'll also help you understand how you can create new keyboard shortcuts using Qt Creator commands.

# Credits

Expand Down
17 changes: 14 additions & 3 deletions qnvimplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <QTextEdit>
#include <QThread>
#include <QtMath>
#include <QStandardPaths>

namespace QNVim {
namespace Internal {
Expand Down Expand Up @@ -164,7 +165,6 @@ QNVimPlugin::QNVimPlugin(): mEnabled(true), mCMDLine(nullptr), mNumbersColumn(nu
mNumber(true), mRelativeNumber(true), mWrap(false),
mCMDLineVisible(false), mUIMode("normal"), mMode("n"), settingBufferFromVim(false),
mSyncCounter(0) {
qputenv("MYQVIMRC", QDir().home().filePath(".qnvimrc").toUtf8());
}

QNVimPlugin::~QNVimPlugin() {
Expand Down Expand Up @@ -537,17 +537,18 @@ function! SetCursor(line, col)\n\
endif\n\
call cursor(a:line, a:col)\n\
endfunction\n\
source ~/.qnvimrc").arg(mNVim->channel())));
autocmd VimEnter * let $MYQVIMRC=substitute($MYVIMRC, 'init.vim$', 'qnvim.vim', v:true) | source $MYQVIMRC").arg(mNVim->channel())));
connect(mNVim->api2(), &NeovimQt::NeovimApi2::neovimNotification,
this, &QNVimPlugin::handleNotification);

QVariantMap options;
options.insert("ext_popupmenu", true);
options.insert("ext_tabline", false);
options.insert("ext_cmdline", true);
options.insert("ext_multigrid", true);
options.insert("ext_wildmenu", true);
options.insert("ext_messages", true);
options.insert("ext_multigrid", true);
options.insert("ext_hlstate", true);
options.insert("rgb", true);
NeovimQt::MsgpackRequest *req = mNVim->api2()->nvim_ui_attach(mWidth, mHeight, options);
connect(req, &NeovimQt::MsgpackRequest::timeout, mNVim, &NeovimQt::NeovimConnector::fatalTimeout);
Expand Down Expand Up @@ -673,6 +674,7 @@ void QNVimPlugin::editorOpened(Core::IEditor *editor) {
return;

QString filename(this->filename(editor));
mText = "";
qWarning() << "Opened " << filename << settingBufferFromVim;

mInitialized[filename] = false;
Expand Down Expand Up @@ -993,6 +995,15 @@ void QNVimPlugin::redraw(const QVariantList &args) {
else if (command == "msg_clear") {
mMessageLineDisplay = "";
}
else if (command == "msg_history_show") {
QVariantList entries = args[1].toList();
mMessageLineDisplay = "";
for (auto entry: entries) {
QVariantList contentList = entry.toList()[1].toList();
for (auto contentItem: contentList)
mMessageLineDisplay += mNVim->decode(contentItem.toList()[1].toByteArray()) + '\n';
}
}
else {
}
}
Expand Down

0 comments on commit 739d12b

Please sign in to comment.