Skip to content

Commit cd5c61f

Browse files
committed
Closes #104 - adds keymap setting
1 parent 82a5a93 commit cd5c61f

File tree

6 files changed

+124
-15
lines changed

6 files changed

+124
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [6.4.0-beta] - 2017-12-02
88
### Added
9+
- Adds `gitlens.keymap` setting to specify the keymap to use for GitLens shortcut keys -- closes [#104](https://github.com/eamodio/vscode-gitlens/issues/104)
10+
- `standard` - adds a standard set of shortcut keys
11+
- `chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)
12+
- `none` - no shortcut keys will be added
913
- Adds progress indicator to the `Show Stashed Changes` command (`gitlens.showQuickStashList`)
1014
- Adds progress indicator to the `Apply Stashed Changes` command (`gitlens.stashApply`)
1115

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ While GitLens is highly customizable and provides many [configuration settings](
2828
|`gitlens.codeLens.enabled`|Specifies whether or not to provide any Git code lens, by default<br />Use the `Toggle Git Code Lens` command (`gitlens.toggleCodeLens`) to toggle the Git code lens on and off for the current session
2929
|`gitlens.gitExplorer.enabled`|Specifies whether or not to show the `GitLens` view
3030
|`gitlens.statusBar.enabled`|Specifies whether or not to provide blame information on the status bar
31+
|`gitlens.keymap`|Specifies the keymap to use for GitLens shortcut keys<br />`standard` - adds a standard set of shortcut keys<br />`chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)<br />`none` - no shortcut keys will be added
3132

3233
## Features
3334

@@ -345,6 +346,7 @@ GitLens is highly customizable and provides many configuration settings to allow
345346
|-----|------------
346347
|`gitlens.defaultDateFormat`|Specifies how all absolute dates will be formatted by default<br />See https://momentjs.com/docs/#/displaying/format/ for valid formats
347348
|`gitlens.insiders`|Opts into the insiders channel -- provides access to upcoming features
349+
|`gitlens.keymap`|Specifies the keymap to use for GitLens shortcut keys<br />`standard` - adds a standard set of shortcut keys<br />`chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)<br />`none` - no shortcut keys will be added
348350
|`gitlens.outputLevel`|Specifies how much (if any) output will be sent to the GitLens output channel
349351

350352
### Blame Settings

package.json

Lines changed: 103 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@
6565
"description": "Specifies whether or not to enable new experimental features (expect there to be issues)",
6666
"scope": "window"
6767
},
68+
"gitlens.keymap": {
69+
"type": "string",
70+
"default": "standard",
71+
"enum": [
72+
"standard",
73+
"chorded",
74+
"none"
75+
],
76+
"description": "Specifies the keymap to use for GitLens shortcut keys\n `standard` - adds a standard set of shortcut keys\n `chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)\n `none` - no shortcut keys will be added",
77+
"scope": "window"
78+
},
6879
"gitlens.outputLevel": {
6980
"type": "string",
7081
"default": "silent",
@@ -2352,67 +2363,145 @@
23522363
{
23532364
"command": "gitlens.toggleFileBlame",
23542365
"key": "alt+b",
2355-
"when": "editorTextFocus && gitlens:activeIsBlameable"
2366+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsBlameable"
23562367
},
23572368
{
23582369
"command": "gitlens.toggleCodeLens",
23592370
"key": "shift+alt+b",
2360-
"when": "editorTextFocus && gitlens:activeIsTracked && gitlens:canToggleCodeLens"
2371+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked && gitlens:canToggleCodeLens"
23612372
},
23622373
{
23632374
"command": "gitlens.showLastQuickPick",
23642375
"key": "alt+-",
2365-
"when": "gitlens:enabled"
2376+
"when": "gitlens:keymap == standard && gitlens:enabled"
23662377
},
23672378
{
23682379
"command": "gitlens.showCommitSearch",
23692380
"key": "alt+/",
2370-
"when": "gitlens:enabled"
2381+
"when": "gitlens:keymap == standard && gitlens:enabled"
23712382
},
23722383
{
23732384
"command": "gitlens.showQuickFileHistory",
23742385
"key": "alt+h",
2375-
"when": "gitlens:enabled"
2386+
"when": "gitlens:keymap == standard && gitlens:enabled"
23762387
},
23772388
{
23782389
"command": "gitlens.showQuickRepoHistory",
23792390
"key": "shift+alt+h",
2380-
"when": "gitlens:enabled"
2391+
"when": "gitlens:keymap == standard && gitlens:enabled"
23812392
},
23822393
{
23832394
"command": "gitlens.showQuickRepoStatus",
23842395
"key": "alt+s",
2385-
"when": "gitlens:enabled"
2396+
"when": "gitlens:keymap == standard && gitlens:enabled"
23862397
},
23872398
{
23882399
"command": "gitlens.showQuickCommitFileDetails",
23892400
"key": "alt+c",
2390-
"when": "editorTextFocus && gitlens:enabled"
2401+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:enabled"
23912402
},
23922403
{
23932404
"command": "gitlens.diffWithNext",
23942405
"key": "alt+.",
2395-
"when": "editorTextFocus && gitlens:activeIsTracked"
2406+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked"
23962407
},
23972408
{
23982409
"command": "gitlens.diffLineWithPrevious",
23992410
"key": "shift+alt+,",
2400-
"when": "editorTextFocus && gitlens:activeIsTracked"
2411+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked"
24012412
},
24022413
{
24032414
"command": "gitlens.diffWithPrevious",
24042415
"key": "alt+,",
2405-
"when": "editorTextFocus && gitlens:activeIsTracked"
2416+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked"
24062417
},
24072418
{
24082419
"command": "gitlens.diffLineWithWorking",
24092420
"key": "alt+w",
2410-
"when": "editorTextFocus && gitlens:activeIsTracked"
2421+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked"
24112422
},
24122423
{
24132424
"command": "gitlens.diffWithWorking",
24142425
"key": "shift+alt+w",
2415-
"when": "editorTextFocus && gitlens:activeIsTracked"
2426+
"when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked"
2427+
},
2428+
{
2429+
"command": "gitlens.toggleFileBlame",
2430+
"key": "ctrl+alt+g b",
2431+
"mac": "cmd+alt+g b",
2432+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsBlameable"
2433+
},
2434+
{
2435+
"command": "gitlens.toggleCodeLens",
2436+
"key": "ctrl+alt+g shift+b",
2437+
"mac": "cmd+alt+g shift+b",
2438+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked && gitlens:canToggleCodeLens"
2439+
},
2440+
{
2441+
"command": "gitlens.showLastQuickPick",
2442+
"key": "ctrl+alt+g -",
2443+
"mac": "cmd+alt+g -",
2444+
"when": "gitlens:keymap == chorded && gitlens:enabled"
2445+
},
2446+
{
2447+
"command": "gitlens.showCommitSearch",
2448+
"key": "ctrl+alt+g /",
2449+
"mac": "cmd+alt+g /",
2450+
"when": "gitlens:keymap == chorded && gitlens:enabled"
2451+
},
2452+
{
2453+
"command": "gitlens.showQuickFileHistory",
2454+
"key": "ctrl+alt+g h",
2455+
"mac": "cmd+alt+g h",
2456+
"when": "gitlens:keymap == chorded && gitlens:enabled"
2457+
},
2458+
{
2459+
"command": "gitlens.showQuickRepoHistory",
2460+
"key": "ctrl+alt+g shift+h",
2461+
"mac": "cmd+alt+g shift+h",
2462+
"when": "gitlens:keymap == chorded && gitlens:enabled"
2463+
},
2464+
{
2465+
"command": "gitlens.showQuickRepoStatus",
2466+
"key": "ctrl+alt+g s",
2467+
"mac": "cmd+alt+g s",
2468+
"when": "gitlens:keymap == chorded && gitlens:enabled"
2469+
},
2470+
{
2471+
"command": "gitlens.showQuickCommitFileDetails",
2472+
"key": "ctrl+alt+g c",
2473+
"mac": "cmd+alt+g c",
2474+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:enabled"
2475+
},
2476+
{
2477+
"command": "gitlens.diffWithNext",
2478+
"key": "ctrl+alt+g .",
2479+
"mac": "cmd+alt+g .",
2480+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
2481+
},
2482+
{
2483+
"command": "gitlens.diffLineWithPrevious",
2484+
"key": "ctrl+alt+g shift+,",
2485+
"mac": "cmd+alt+g shift+,",
2486+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
2487+
},
2488+
{
2489+
"command": "gitlens.diffWithPrevious",
2490+
"key": "ctrl+alt+g ,",
2491+
"mac": "cmd+alt+g ,",
2492+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
2493+
},
2494+
{
2495+
"command": "gitlens.diffLineWithWorking",
2496+
"key": "ctrl+alt+g w",
2497+
"mac": "cmd+alt+g w",
2498+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
2499+
},
2500+
{
2501+
"command": "gitlens.diffWithWorking",
2502+
"key": "ctrl+alt+g shift+w",
2503+
"mac": "cmd+alt+g shift+w",
2504+
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
24162505
}
24172506
],
24182507
"views": {
@@ -2464,4 +2553,4 @@
24642553
"typescript": "2.6.2",
24652554
"vscode": "1.1.10"
24662555
}
2467-
}
2556+
}

src/configuration.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export enum GitExplorerFilesLayout {
4444
Tree = 'tree'
4545
}
4646

47+
export enum KeyMap {
48+
Standard = 'standard',
49+
Chorded = 'chorded',
50+
None = 'none'
51+
}
52+
4753
export enum StatusBarCommand {
4854
DiffWithPrevious = 'gitlens.diffWithPrevious',
4955
DiffWithWorking = 'gitlens.diffWithWorking',
@@ -254,6 +260,8 @@ export interface IConfig {
254260

255261
gitExplorer: IGitExplorerConfig;
256262

263+
keymap: KeyMap;
264+
257265
remotes: IRemotesConfig[];
258266

259267
statusBar: {
@@ -384,6 +392,7 @@ const emptyConfig: IConfig = {
384392
statusFileFormat: ''
385393
// dateFormat: string | null;
386394
},
395+
keymap: 'standard' as KeyMap,
387396
remotes: [],
388397
statusBar: {
389398
enabled: false,

src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export enum CommandContext {
3838
ActiveHasRemote = 'gitlens:activeHasRemote',
3939
ActiveIsBlameable = 'gitlens:activeIsBlameable',
4040
ActiveFileIsTracked = 'gitlens:activeIsTracked',
41-
Key = 'gitlens:key'
41+
Key = 'gitlens:key',
42+
KeyMap = 'gitlens:keymap'
4243
}
4344

4445
export function setCommandContext(key: CommandContext | string, value: any) {

src/gitService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ export class GitService extends Disposable {
153153

154154
const cfg = configuration.get<IConfig>();
155155

156+
if (initializing || configuration.changed(e, configuration.name('keymap').value)) {
157+
setCommandContext(CommandContext.KeyMap, cfg.keymap);
158+
}
159+
156160
if (initializing || configuration.changed(e, configuration.name('advanced')('caching')('enabled').value)) {
157161
if (cfg.advanced.caching.enabled) {
158162
this._cacheDisposable && this._cacheDisposable.dispose();

0 commit comments

Comments
 (0)