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

Granular Status Bar item color control #9232

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,116 @@
}
}
},
"colors": [
{
"id": "statusBarItem.vimMode.Normal",
"description": "Vim status bar color for normal mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.Insert",
"description": "Vim status bar color for insert mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.Visual",
"description": "Vim status bar color for visual mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.VisualBlock",
"description": "Vim status bar color for visual block mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.VisualLine",
"description": "Vim status bar color for visual line mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.Replace",
"description": "Vim status bar color for replace mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.EasyMotionMode",
"description": "Vim status bar color for easy motion mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.EasyMotionInputMode",
"description": "Vim status bar color for easy motion input mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.SurroundInputMode",
"description": "Vim status bar color for surround input mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.Disabled",
"description": "Vim status bar color for disabled mode.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.SearchInProgressMode",
"description": "Vim status bar color for when a search is in progress.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
},
{
"id": "statusBarItem.vimMode.CommandlineInProgress",
"description": "Vim status bar color for when entering a command.",
"defaults": {
"dark": "statusBar.foreground",
"light": "statusBar.foreground",
"highContrast": "statusBar.foreground"
}
}
],
"languages": [
{
"id": "Vimscript",
Expand Down
23 changes: 18 additions & 5 deletions src/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ class StatusBarImpl implements vscode.Disposable {
}

// StatusBar color
const shouldUpdateColor =
configuration.statusBarColorControl && vimState.currentMode !== this.previousMode;
if (shouldUpdateColor) {
this.updateColor(vimState.currentMode);
}
this.updateColor(vimState.currentMode);

this.previousMode = vimState.currentMode;
this.showingDefaultMessage = false;
Expand Down Expand Up @@ -122,6 +118,23 @@ class StatusBarImpl implements vscode.Disposable {
}

private updateColor(mode: Mode) {
// original color update method - applies to the whole line by modifying the user's settings
if (configuration.statusBarColorControl && mode !== this.previousMode) {
this.updateWholeStatusBarColor(mode);
}

// narrow color update method - applies to the Vim status bar items based on color settings
this.updateVimStatusBarItemColor(mode);
}

private updateVimStatusBarItemColor(mode: Mode) {
const modeName = Mode[mode];
const foregroundColor = new vscode.ThemeColor(`statusBarItem.vimMode.${modeName}`);
this.statusBarItem.color = foregroundColor;
this.recordedStateStatusBarItem.color = foregroundColor;
}

private updateWholeStatusBarColor(mode: Mode) {
let foreground: string | undefined;
let background: string | undefined;

Expand Down