Skip to content

Commit

Permalink
Merge pull request #2878 from xconverge/neovim-indentation
Browse files Browse the repository at this point in the history
Improve neovim command execution status reporting in status bar
  • Loading branch information
xconverge authored Jul 25, 2018
2 parents b83139c + bc50c84 commit 3d325e9
Showing 1 changed file with 19 additions and 10 deletions.
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

0 comments on commit 3d325e9

Please sign in to comment.