From cd5c61f9c611f241b0cc36e8466ff3d6a7ab8e93 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 12 Dec 2017 13:53:59 -0500 Subject: [PATCH] Closes #104 - adds keymap setting --- CHANGELOG.md | 4 ++ README.md | 2 + package.json | 117 +++++++++++++++++++++++++++++++++++++++++++++------ src/configuration.ts | 9 ++++ src/constants.ts | 3 +- src/gitService.ts | 4 ++ 6 files changed, 124 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f4f26e..e2c0abc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [6.4.0-beta] - 2017-12-02 ### Added +- Adds `gitlens.keymap` setting to specify the keymap to use for GitLens shortcut keys -- closes [#104](https://github.com/eamodio/vscode-gitlens/issues/104) + - `standard` - adds a standard set of shortcut keys + - `chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS) + - `none` - no shortcut keys will be added - Adds progress indicator to the `Show Stashed Changes` command (`gitlens.showQuickStashList`) - Adds progress indicator to the `Apply Stashed Changes` command (`gitlens.stashApply`) diff --git a/README.md b/README.md index f82ab74..1b5a07f 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ While GitLens is highly customizable and provides many [configuration settings]( |`gitlens.codeLens.enabled`|Specifies whether or not to provide any Git code lens, by default
Use the `Toggle Git Code Lens` command (`gitlens.toggleCodeLens`) to toggle the Git code lens on and off for the current session |`gitlens.gitExplorer.enabled`|Specifies whether or not to show the `GitLens` view |`gitlens.statusBar.enabled`|Specifies whether or not to provide blame information on the status bar +|`gitlens.keymap`|Specifies the keymap to use for GitLens shortcut keys
`standard` - adds a standard set of shortcut keys
`chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)
`none` - no shortcut keys will be added ## Features @@ -345,6 +346,7 @@ GitLens is highly customizable and provides many configuration settings to allow |-----|------------ |`gitlens.defaultDateFormat`|Specifies how all absolute dates will be formatted by default
See https://momentjs.com/docs/#/displaying/format/ for valid formats |`gitlens.insiders`|Opts into the insiders channel -- provides access to upcoming features +|`gitlens.keymap`|Specifies the keymap to use for GitLens shortcut keys
`standard` - adds a standard set of shortcut keys
`chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)
`none` - no shortcut keys will be added |`gitlens.outputLevel`|Specifies how much (if any) output will be sent to the GitLens output channel ### Blame Settings diff --git a/package.json b/package.json index 3f4fe19..e160a50 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,17 @@ "description": "Specifies whether or not to enable new experimental features (expect there to be issues)", "scope": "window" }, + "gitlens.keymap": { + "type": "string", + "default": "standard", + "enum": [ + "standard", + "chorded", + "none" + ], + "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", + "scope": "window" + }, "gitlens.outputLevel": { "type": "string", "default": "silent", @@ -2352,67 +2363,145 @@ { "command": "gitlens.toggleFileBlame", "key": "alt+b", - "when": "editorTextFocus && gitlens:activeIsBlameable" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsBlameable" }, { "command": "gitlens.toggleCodeLens", "key": "shift+alt+b", - "when": "editorTextFocus && gitlens:activeIsTracked && gitlens:canToggleCodeLens" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked && gitlens:canToggleCodeLens" }, { "command": "gitlens.showLastQuickPick", "key": "alt+-", - "when": "gitlens:enabled" + "when": "gitlens:keymap == standard && gitlens:enabled" }, { "command": "gitlens.showCommitSearch", "key": "alt+/", - "when": "gitlens:enabled" + "when": "gitlens:keymap == standard && gitlens:enabled" }, { "command": "gitlens.showQuickFileHistory", "key": "alt+h", - "when": "gitlens:enabled" + "when": "gitlens:keymap == standard && gitlens:enabled" }, { "command": "gitlens.showQuickRepoHistory", "key": "shift+alt+h", - "when": "gitlens:enabled" + "when": "gitlens:keymap == standard && gitlens:enabled" }, { "command": "gitlens.showQuickRepoStatus", "key": "alt+s", - "when": "gitlens:enabled" + "when": "gitlens:keymap == standard && gitlens:enabled" }, { "command": "gitlens.showQuickCommitFileDetails", "key": "alt+c", - "when": "editorTextFocus && gitlens:enabled" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:enabled" }, { "command": "gitlens.diffWithNext", "key": "alt+.", - "when": "editorTextFocus && gitlens:activeIsTracked" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked" }, { "command": "gitlens.diffLineWithPrevious", "key": "shift+alt+,", - "when": "editorTextFocus && gitlens:activeIsTracked" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked" }, { "command": "gitlens.diffWithPrevious", "key": "alt+,", - "when": "editorTextFocus && gitlens:activeIsTracked" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked" }, { "command": "gitlens.diffLineWithWorking", "key": "alt+w", - "when": "editorTextFocus && gitlens:activeIsTracked" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked" }, { "command": "gitlens.diffWithWorking", "key": "shift+alt+w", - "when": "editorTextFocus && gitlens:activeIsTracked" + "when": "gitlens:keymap == standard && editorTextFocus && gitlens:activeIsTracked" + }, + { + "command": "gitlens.toggleFileBlame", + "key": "ctrl+alt+g b", + "mac": "cmd+alt+g b", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsBlameable" + }, + { + "command": "gitlens.toggleCodeLens", + "key": "ctrl+alt+g shift+b", + "mac": "cmd+alt+g shift+b", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked && gitlens:canToggleCodeLens" + }, + { + "command": "gitlens.showLastQuickPick", + "key": "ctrl+alt+g -", + "mac": "cmd+alt+g -", + "when": "gitlens:keymap == chorded && gitlens:enabled" + }, + { + "command": "gitlens.showCommitSearch", + "key": "ctrl+alt+g /", + "mac": "cmd+alt+g /", + "when": "gitlens:keymap == chorded && gitlens:enabled" + }, + { + "command": "gitlens.showQuickFileHistory", + "key": "ctrl+alt+g h", + "mac": "cmd+alt+g h", + "when": "gitlens:keymap == chorded && gitlens:enabled" + }, + { + "command": "gitlens.showQuickRepoHistory", + "key": "ctrl+alt+g shift+h", + "mac": "cmd+alt+g shift+h", + "when": "gitlens:keymap == chorded && gitlens:enabled" + }, + { + "command": "gitlens.showQuickRepoStatus", + "key": "ctrl+alt+g s", + "mac": "cmd+alt+g s", + "when": "gitlens:keymap == chorded && gitlens:enabled" + }, + { + "command": "gitlens.showQuickCommitFileDetails", + "key": "ctrl+alt+g c", + "mac": "cmd+alt+g c", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:enabled" + }, + { + "command": "gitlens.diffWithNext", + "key": "ctrl+alt+g .", + "mac": "cmd+alt+g .", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked" + }, + { + "command": "gitlens.diffLineWithPrevious", + "key": "ctrl+alt+g shift+,", + "mac": "cmd+alt+g shift+,", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked" + }, + { + "command": "gitlens.diffWithPrevious", + "key": "ctrl+alt+g ,", + "mac": "cmd+alt+g ,", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked" + }, + { + "command": "gitlens.diffLineWithWorking", + "key": "ctrl+alt+g w", + "mac": "cmd+alt+g w", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked" + }, + { + "command": "gitlens.diffWithWorking", + "key": "ctrl+alt+g shift+w", + "mac": "cmd+alt+g shift+w", + "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked" } ], "views": { @@ -2464,4 +2553,4 @@ "typescript": "2.6.2", "vscode": "1.1.10" } -} +} \ No newline at end of file diff --git a/src/configuration.ts b/src/configuration.ts index 8f532d3..2a70d4e 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -44,6 +44,12 @@ export enum GitExplorerFilesLayout { Tree = 'tree' } +export enum KeyMap { + Standard = 'standard', + Chorded = 'chorded', + None = 'none' +} + export enum StatusBarCommand { DiffWithPrevious = 'gitlens.diffWithPrevious', DiffWithWorking = 'gitlens.diffWithWorking', @@ -254,6 +260,8 @@ export interface IConfig { gitExplorer: IGitExplorerConfig; + keymap: KeyMap; + remotes: IRemotesConfig[]; statusBar: { @@ -384,6 +392,7 @@ const emptyConfig: IConfig = { statusFileFormat: '' // dateFormat: string | null; }, + keymap: 'standard' as KeyMap, remotes: [], statusBar: { enabled: false, diff --git a/src/constants.ts b/src/constants.ts index 24419a5..197d3a9 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -38,7 +38,8 @@ export enum CommandContext { ActiveHasRemote = 'gitlens:activeHasRemote', ActiveIsBlameable = 'gitlens:activeIsBlameable', ActiveFileIsTracked = 'gitlens:activeIsTracked', - Key = 'gitlens:key' + Key = 'gitlens:key', + KeyMap = 'gitlens:keymap' } export function setCommandContext(key: CommandContext | string, value: any) { diff --git a/src/gitService.ts b/src/gitService.ts index bbae1f2..fb0bf15 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -153,6 +153,10 @@ export class GitService extends Disposable { const cfg = configuration.get(); + if (initializing || configuration.changed(e, configuration.name('keymap').value)) { + setCommandContext(CommandContext.KeyMap, cfg.keymap); + } + if (initializing || configuration.changed(e, configuration.name('advanced')('caching')('enabled').value)) { if (cfg.advanced.caching.enabled) { this._cacheDisposable && this._cacheDisposable.dispose();