Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve neovim command execution status reporting in status bar #2878

Merged
merged 8 commits into from
Jul 25, 2018
29 changes: 19 additions & 10 deletions src/neovim/neovim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,38 @@ export class Neovim implements vscode.Disposable {
command = ':' + command + '\n';
command = command.replace('<', '<lt>');

// Clear the previous error code. API does not allow setVvar so do it manually
await this.nvim.command('let v:errmsg=""');
// Clear the previous error and status messages. API does not allow setVvar
// so do it manually
await this.nvim.command('let v:errmsg="" | let v:statusmsg=""');

// Execute the command
await this.nvim.input(command);
if ((await this.nvim.getMode()).blocking) {
await this.nvim.input('<esc>');
}

// Check if an error occurred, then sync buffer back to vscode
// Check if an error occurred
const errMsg = await this.nvim.getVvar('errmsg');
let statusBarText = '';
if (errMsg && errMsg.toString() !== '') {
StatusBar.SetText(
errMsg.toString(),
vimState.currentMode,
vimState.isRecordingMacro,
true,
true
);
statusBarText = errMsg.toString();
} else {
// Check to see if a status message was updated
const statusMsg = await this.nvim.getVvar('statusmsg');
if (statusMsg && statusMsg.toString() !== '') {
statusBarText = statusMsg.toString();
}
}

// TODO xconverge: only do this if a command was successful, but be mindful
// of indentation changes that were made

// Sync buffer back to vscode
await this.syncVimToVs(vimState);

// Lastly update the status bar
StatusBar.SetText(statusBarText, vimState.currentMode, vimState.isRecordingMacro, true, true);

return;
}

Expand Down