Skip to content

Commit

Permalink
Closes #104 - adds keymap setting
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 12, 2017
1 parent 82a5a93 commit cd5c61f
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br />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<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

## Features

Expand Down Expand Up @@ -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<br />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<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
|`gitlens.outputLevel`|Specifies how much (if any) output will be sent to the GitLens output channel

### Blame Settings
Expand Down
117 changes: 103 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -2464,4 +2553,4 @@
"typescript": "2.6.2",
"vscode": "1.1.10"
}
}
}
9 changes: 9 additions & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -254,6 +260,8 @@ export interface IConfig {

gitExplorer: IGitExplorerConfig;

keymap: KeyMap;

remotes: IRemotesConfig[];

statusBar: {
Expand Down Expand Up @@ -384,6 +392,7 @@ const emptyConfig: IConfig = {
statusFileFormat: ''
// dateFormat: string | null;
},
keymap: 'standard' as KeyMap,
remotes: [],
statusBar: {
enabled: false,
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export class GitService extends Disposable {

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

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();
Expand Down

0 comments on commit cd5c61f

Please sign in to comment.