Skip to content

Commit eafddea

Browse files
authored
Merge pull request #463 from jinghaihan/feat/align-priority
feat: custom status bar item position
2 parents a9648c4 + 6391e49 commit eafddea

4 files changed

Lines changed: 49 additions & 6 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ For example, to hide today's coding activity in your status bar:
3636

3737
Press `⌘ + Shift + P` then set `WakaTime: Status Bar Coding Activity` to `false`.
3838

39+
### Status Bar Alignment
40+
41+
You can customize the position and priority of the WakaTime status bar item:
42+
43+
- **Alignment**: Set `wakatime.align` to `left` or `right` to control which side of the status bar shows the WakaTime item
44+
- **Priority**: Set `wakatime.alignPriority` to a number to control the order (higher values appear more to the left)
45+
46+
Both settings require restarting VS Code to take effect.
47+
3948
Extension settings are stored in the INI file at `$HOME/.wakatime.cfg`.
4049

4150
More information can be found from [wakatime-cli][wakatime-cli configs].

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@
127127
"type": "string",
128128
"description": "Defaults to https://api.wakatime.com/api/v1.",
129129
"scope": "application"
130+
},
131+
"wakatime.align": {
132+
"type": "string",
133+
"enum": [
134+
"left",
135+
"right"
136+
],
137+
"default": "left",
138+
"description": "Defines the alignment of the status bar item, requires restart of VS Code"
139+
},
140+
"wakatime.alignPriority": {
141+
"type": "number",
142+
"default": 1,
143+
"description": "Defines priority of the status bar item. Higher values mean the item should be shown more to the left, requires restart of VS Code"
130144
}
131145
}
132146
}

src/options.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,23 @@ export class Options {
309309
return vscode.workspace.getConfiguration().get('wakatime.apiUrl') || '';
310310
}
311311

312+
public getStatusBarAlignment(): vscode.StatusBarAlignment {
313+
const align: string = vscode.workspace.getConfiguration().get('wakatime.align') as string
314+
switch (align) {
315+
case 'left':
316+
return vscode.StatusBarAlignment.Left
317+
case 'right':
318+
return vscode.StatusBarAlignment.Right
319+
default:
320+
return vscode.StatusBarAlignment.Left
321+
}
322+
}
323+
324+
public getStatusBarPriority(): number {
325+
const priority = vscode.workspace.getConfiguration().get('wakatime.alignPriority') as number;
326+
return typeof priority === 'number' ? priority : 1;
327+
}
328+
312329
// Support for gitpod.io https://github.com/wakatime/vscode-wakatime/pull/220
313330
public getApiKeyFromEnv(): string {
314331
if (this.cache.api_key_from_env !== undefined) return this.cache.api_key_from_env;

src/wakatime.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,28 @@ export class WakaTime {
123123
public initializeDependencies(): void {
124124
this.logger.debug(`Initializing WakaTime v${this.extension.version}`);
125125

126+
const align = this.options.getStatusBarAlignment();
127+
const priority = this.options.getStatusBarPriority();
128+
126129
this.statusBar = vscode.window.createStatusBarItem(
127130
'com.wakatime.statusbar',
128-
vscode.StatusBarAlignment.Left,
129-
3,
131+
align,
132+
priority + 2,
130133
);
131134
this.statusBar.name = 'WakaTime';
132135
this.statusBar.command = COMMAND_DASHBOARD;
133136

134137
this.statusBarTeamYou = vscode.window.createStatusBarItem(
135138
'com.wakatime.teamyou',
136-
vscode.StatusBarAlignment.Left,
137-
2,
139+
align,
140+
priority + 1,
138141
);
139142
this.statusBarTeamYou.name = 'WakaTime Top dev';
140143

141144
this.statusBarTeamOther = vscode.window.createStatusBarItem(
142145
'com.wakatime.teamother',
143-
vscode.StatusBarAlignment.Left,
144-
1,
146+
align,
147+
priority,
145148
);
146149
this.statusBarTeamOther.name = 'WakaTime Team Total';
147150

0 commit comments

Comments
 (0)