Skip to content

Commit

Permalink
Merge pull request #1529 from xconverge/change-status-bar
Browse files Browse the repository at this point in the history
Allow user to change status bar color based on mode
  • Loading branch information
xconverge committed Apr 19, 2017
2 parents 2a3b69b + d80999a commit b8ac4cd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ VSCodeVim is a [Visual Studio Code](https://code.visualstudio.com/) extension th
* The [EasyMotion plugin](#how-to-use-easymotion)
* The [Surround.vim plugin](#how-to-use-surround)
* The [Commentary plugin](#how-to-use-commentary)
* The [Vim-airline plugin](#statusbarcolorcontrol)
* And much more! Refer to the [roadmap](ROADMAP.md) or everything we support.

Please [report missing features/bugs on GitHub](https://github.com/VSCodeVim/Vim/issues), which will help us get to them faster.
Expand Down Expand Up @@ -213,6 +214,25 @@ Or bind ctrl+n to turn off search highlighting and `<leader>w` to save the curre
* Use a non-blinking block cursor
* Type: Boolean (Default: `false`)


#### statusBarColorControl
* Control status bar color based on current mode
* Type: Boolean (Default: `false`)

Once this is set, you need to set statusBarColors as well with these exact strings for modenames. The colors can be adjusted to suit the user.

```
"vim.statusBarColorControl": true,
"vim.statusBarColors" : {
"normal": "#005f5f",
"insert": "#5f0000",
"visual": "#5f00af",
"visualline": "#005f87",
"visualblock": "#86592d",
"replace": "#000000"
}
```

### Vim settings we support

#### ignorecase
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@
"vim.handleKeys": {
"type": "object",
"description": "Option to delegate certain key combinations back to VSCode to be handled natively"
},
"vim.statusBarColorControl":{
"type": "boolean",
"description": "Allow VSCodeVim to change status bar color based on mode"
},
"vim.statusBarColors": {
"type": "object",
"description": "Customize colors per mode when VSCodeVim controls status bar colors"
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export interface IHandleKeys {
[key: string]: boolean;
}

export interface IStatusBarColors {
[key: string]: string;
}

/**
* Every Vim option we support should
* 1. Be added to contribution section of `package.json`.
Expand Down Expand Up @@ -215,6 +219,16 @@ class ConfigurationClass {
*/
startInInsertMode = false;

/**
* Start in insert mode?
*/
statusBarColorControl = false;

/**
* Status bar colors to change to based on mode
*/
statusBarColors: IStatusBarColors = {};

/**
* Color of search highlights.
*/
Expand Down
18 changes: 17 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1795,12 +1795,19 @@ export class ModeHandler implements vscode.Disposable {

this._vimState.editor.setDecorations(this._searchHighlightDecoration, searchRanges);


for (let i = 0; i < this.vimState.postponedCodeViewChanges.length; i++) {
let viewChange = this.vimState.postponedCodeViewChanges[i];
await vscode.commands.executeCommand(viewChange.command, viewChange.args);
}

// If user wants to change status bar color based on mode
if (Configuration.statusBarColorControl) {
let colorToSet = Configuration.statusBarColors[this._vimState.currentModeName().toLowerCase()];
if (colorToSet !== undefined) {
this.setStatusBarColor(colorToSet);
}
}

this.vimState.postponedCodeViewChanges = [];

if (this.currentMode.name === ModeName.SearchInProgressMode) {
Expand Down Expand Up @@ -1863,6 +1870,15 @@ export class ModeHandler implements vscode.Disposable {
ModeHandler._statusBarItem.show();
}

setStatusBarColor(color: string): void {
vscode.workspace.getConfiguration("workbench.experimental").update("colorCustomizations",
{
"statusBarBackground": `${color}`,
"statusBarNoFolderBackground": `${color}`,
"statusBarDebuggingBackground": `${color}`
});
}

// Return true if a new undo point should be created based on brackets and parenthesis
private createUndoPointForBrackets(vimState: VimState): boolean {
// }])> keys all start a new undo state when directly next to an {[(< opening character
Expand Down

0 comments on commit b8ac4cd

Please sign in to comment.