From 8f66f66647713db6360ce692f3d78a883b23c829 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 18 Apr 2017 19:41:38 -0700 Subject: [PATCH 1/3] Allow user to change status bar color based on mode --- package.json | 8 ++++++++ src/configuration/configuration.ts | 14 ++++++++++++++ src/mode/modeHandler.ts | 18 +++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 31f98ee0398..576ecefb941 100644 --- a/package.json +++ b/package.json @@ -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" } } } diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index 47d5c5637e0..5e3ca857532 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -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`. @@ -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. */ diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index eecc7d0af1e..0d57c02b938 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -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) { @@ -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 From da8869ced142525092c359b4fd170d71dc3e124a Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 18 Apr 2017 20:06:23 -0700 Subject: [PATCH 2/3] update readme for status bar color changing --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 4a7c6b71c71..3281025a258 100644 --- a/README.md +++ b/README.md @@ -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. @@ -213,6 +214,25 @@ Or bind ctrl+n to turn off search highlighting and `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 From d80999a880e3f2a28bb6ec9fbdd31899eca45c71 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 18 Apr 2017 20:07:43 -0700 Subject: [PATCH 3/3] fix mistake in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3281025a258..2cb0dd8ac6b 100644 --- a/README.md +++ b/README.md @@ -12,7 +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) +* 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.