mirror of
https://github.com/Silverquark/dance.git
synced 2024-09-11 18:48:00 +03:00
Now changing editor.lineNumbers along with insert/normal mode.
This commit is contained in:
parent
c603279639
commit
8b26ecfd97
@ -57,6 +57,13 @@ For most [commands], the usage is the same as in [Kakoune]. However, the followi
|
||||
- `i + 1` replaces `1,1,1,1,1` into `1,2,3,4,5`, assuming that each selection is on a different digit.
|
||||
|
||||
|
||||
### Miscellaneous changes
|
||||
- Changing the mode will also change the `editor.lineNumbers` configuration value to `on` in `insert`
|
||||
mode, and `relative` in normal mode. This behavior cannot be disabled, but if you'd like to
|
||||
submit a PR to make this optional, please do!^(This feature is implemented in [`src/extension.ts`](./src/extention.ts),
|
||||
in function `onActiveModeChanged`).
|
||||
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
Dance uses the built-in VS Code key bindings, and therefore does not override the `type` command.
|
||||
|
@ -26,10 +26,10 @@ They are implemented in [`src/commands`](../src/commands).
|
||||
| `dance.newLine.below` | Add new line below | Add a new line below, without entering insert mode. | |
|
||||
| `dance.newLine.above` | Add new line above | Add a new line above, without entering insert mode. | |
|
||||
| `dance.repeat.insert` | Repeat last insert-mode change | Repeat last insert-mode change. | `.` (`dance.mode == 'normal'`) |
|
||||
| `dance.left` | Move left | Move left. | `Left` (`dance.mode == 'normal'`), `Left` (`dance.mode == 'insert'`), `H` (`dance.mode == 'normal'`) |
|
||||
| `dance.right` | Move right | Move right. | `Right` (`dance.mode == 'normal'`), `Right` (`dance.mode == 'insert'`), `L` (`dance.mode == 'normal'`) |
|
||||
| `dance.up` | Move up | Move up. | `Up` (`dance.mode == 'normal'`), `Up` (`dance.mode == 'insert'`), `K` (`dance.mode == 'normal'`) |
|
||||
| `dance.down` | Move down | Move down. | `Down` (`dance.mode == 'normal'`), `Down` (`dance.mode == 'insert'`), `J` (`dance.mode == 'normal'`) |
|
||||
| `dance.left` | Move left | Move left. | `Left` (`dance.mode == 'normal'`), `H` (`dance.mode == 'normal'`) |
|
||||
| `dance.right` | Move right | Move right. | `Right` (`dance.mode == 'normal'`), `L` (`dance.mode == 'normal'`) |
|
||||
| `dance.up` | Move up | Move up. | `Up` (`dance.mode == 'normal'`), `K` (`dance.mode == 'normal'`) |
|
||||
| `dance.down` | Move down | Move down. | `Down` (`dance.mode == 'normal'`), `J` (`dance.mode == 'normal'`) |
|
||||
| `dance.select.to.included` | Select to | Select to the next character pressed, including it. | `F` (`dance.mode == 'normal'`) |
|
||||
| `dance.select.to.excluded` | Select until | Select until the next character pressed, excluding it. | `T` (`dance.mode == 'normal'`) |
|
||||
| `dance.select.buffer` | Select whole buffer | Select whole buffer. | `Shift+5` (`dance.mode == 'normal'`) |
|
||||
@ -106,10 +106,10 @@ They are implemented in [`src/commands`](../src/commands).
|
||||
| `dance.marks.restoreSelections` | Restore selections | Restore selections. | `Z` (`dance.mode == 'normal'`) |
|
||||
| `dance.marks.combineSelections.fromCurrent` | Combine current selections with ones from register | Combine current selections with ones from register. | `Shift+Alt+Z` (`dance.mode == 'normal'`) |
|
||||
| `dance.marks.combineSelections.fromRegister` | Combine register selections with current ones | Combine register selections with current ones. | `Alt+Z` (`dance.mode == 'normal'`) |
|
||||
| `dance.left.extend` | Move left (extend) | Move left (extend). | `Shift+Left` (`dance.mode == 'normal'`), `Left` (`dance.mode == 'insert'`), `H` (`dance.mode == 'normal'`) |
|
||||
| `dance.right.extend` | Move right (extend) | Move right (extend). | `Shift+Right` (`dance.mode == 'normal'`), `Right` (`dance.mode == 'insert'`), `L` (`dance.mode == 'normal'`) |
|
||||
| `dance.up.extend` | Move up (extend) | Move up (extend). | `Shift+Up` (`dance.mode == 'normal'`), `Up` (`dance.mode == 'insert'`), `K` (`dance.mode == 'normal'`) |
|
||||
| `dance.down.extend` | Move down (extend) | Move down (extend). | `Shift+Down` (`dance.mode == 'normal'`), `Down` (`dance.mode == 'insert'`), `J` (`dance.mode == 'normal'`) |
|
||||
| `dance.left.extend` | Move left (extend) | Move left (extend). | `Shift+Left` (`dance.mode == 'normal'`), `H` (`dance.mode == 'normal'`) |
|
||||
| `dance.right.extend` | Move right (extend) | Move right (extend). | `Shift+Right` (`dance.mode == 'normal'`), `L` (`dance.mode == 'normal'`) |
|
||||
| `dance.up.extend` | Move up (extend) | Move up (extend). | `Shift+Up` (`dance.mode == 'normal'`), `K` (`dance.mode == 'normal'`) |
|
||||
| `dance.down.extend` | Move down (extend) | Move down (extend). | `Shift+Down` (`dance.mode == 'normal'`), `J` (`dance.mode == 'normal'`) |
|
||||
| `dance.select.to.included.extend` | Extend to | Extend to the next character pressed, including it. | `Shift+F` (`dance.mode == 'normal'`) |
|
||||
| `dance.select.to.excluded.extend` | Extend until | Extend with until the next character pressed, excluding it. | `Shift+T` (`dance.mode == 'normal'`) |
|
||||
| `dance.select.line.extend` | Extend with line | Extend with line on which the end of each selection lies (or next line when end lies on an end-of-line). | `Shift+X` (`dance.mode == 'normal'`) |
|
||||
|
@ -82,19 +82,19 @@ repeat.insert:
|
||||
|
||||
left:
|
||||
title: Move left
|
||||
keys: left (normal), left (insert), h (normal)
|
||||
keys: left (normal), h (normal)
|
||||
add: extend
|
||||
right:
|
||||
title: Move right
|
||||
keys: right (normal), right (insert), l (normal)
|
||||
keys: right (normal), l (normal)
|
||||
add: extend
|
||||
up:
|
||||
title: Move up
|
||||
keys: up (normal), up (insert), k (normal)
|
||||
keys: up (normal), k (normal)
|
||||
add: extend
|
||||
down:
|
||||
title: Move down
|
||||
keys: down (normal), down (insert), j (normal)
|
||||
keys: down (normal), j (normal)
|
||||
add: extend
|
||||
|
||||
|
||||
|
@ -133,7 +133,6 @@ export const left: ICommand & { readonly id: 'dance.left' } = {
|
||||
description: 'Move left.',
|
||||
keybindings: [
|
||||
{ key: 'left', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'left', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'h', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -144,7 +143,6 @@ export const right: ICommand & { readonly id: 'dance.right' } = {
|
||||
description: 'Move right.',
|
||||
keybindings: [
|
||||
{ key: 'right', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'right', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'l', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -155,7 +153,6 @@ export const up: ICommand & { readonly id: 'dance.up' } = {
|
||||
description: 'Move up.',
|
||||
keybindings: [
|
||||
{ key: 'up', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'up', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'k', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -166,7 +163,6 @@ export const down: ICommand & { readonly id: 'dance.down' } = {
|
||||
description: 'Move down.',
|
||||
keybindings: [
|
||||
{ key: 'down', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'down', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'j', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -862,7 +858,6 @@ export const leftExtend: ICommand & { readonly id: 'dance.left.extend' } = {
|
||||
description: 'Move left (extend).',
|
||||
keybindings: [
|
||||
{ key: 'Shift+left', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'left', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'h', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -873,7 +868,6 @@ export const rightExtend: ICommand & { readonly id: 'dance.right.extend' } = {
|
||||
description: 'Move right (extend).',
|
||||
keybindings: [
|
||||
{ key: 'Shift+right', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'right', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'l', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -884,7 +878,6 @@ export const upExtend: ICommand & { readonly id: 'dance.up.extend' } = {
|
||||
description: 'Move up (extend).',
|
||||
keybindings: [
|
||||
{ key: 'Shift+up', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'up', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'k', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
@ -895,7 +888,6 @@ export const downExtend: ICommand & { readonly id: 'dance.down.extend' } = {
|
||||
description: 'Move down (extend).',
|
||||
keybindings: [
|
||||
{ key: 'Shift+down', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
{ key: 'down', when: 'editorTextFocus && dance.mode == \'insert\'' },
|
||||
{ key: 'j', when: 'editorTextFocus && dance.mode == \'normal\'' },
|
||||
],
|
||||
}
|
||||
|
40
package.json
40
package.json
@ -883,11 +883,6 @@
|
||||
"key": "left",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.left",
|
||||
"key": "left",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.left",
|
||||
"key": "h",
|
||||
@ -898,11 +893,6 @@
|
||||
"key": "right",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.right",
|
||||
"key": "right",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.right",
|
||||
"key": "l",
|
||||
@ -913,11 +903,6 @@
|
||||
"key": "up",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.up",
|
||||
"key": "up",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.up",
|
||||
"key": "k",
|
||||
@ -928,11 +913,6 @@
|
||||
"key": "down",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.down",
|
||||
"key": "down",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.down",
|
||||
"key": "j",
|
||||
@ -1333,11 +1313,6 @@
|
||||
"key": "Shift+left",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.left.extend",
|
||||
"key": "left",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.left.extend",
|
||||
"key": "h",
|
||||
@ -1348,11 +1323,6 @@
|
||||
"key": "Shift+right",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.right.extend",
|
||||
"key": "right",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.right.extend",
|
||||
"key": "l",
|
||||
@ -1363,11 +1333,6 @@
|
||||
"key": "Shift+up",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.up.extend",
|
||||
"key": "up",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.up.extend",
|
||||
"key": "k",
|
||||
@ -1378,11 +1343,6 @@
|
||||
"key": "Shift+down",
|
||||
"when": "editorTextFocus && dance.mode == 'normal'"
|
||||
},
|
||||
{
|
||||
"command": "dance.down.extend",
|
||||
"key": "down",
|
||||
"when": "editorTextFocus && dance.mode == 'insert'"
|
||||
},
|
||||
{
|
||||
"command": "dance.down.extend",
|
||||
"key": "j",
|
||||
|
@ -68,7 +68,7 @@ export class Extension implements vscode.Disposable {
|
||||
return state
|
||||
}
|
||||
|
||||
setEditorMode(editor: vscode.TextEditor, mode: Mode): Thenable<void> {
|
||||
setEditorMode(editor: vscode.TextEditor, mode: Mode) {
|
||||
if (this.modeMap.get(editor) === mode)
|
||||
return Promise.resolve()
|
||||
|
||||
@ -87,10 +87,13 @@ export class Extension implements vscode.Disposable {
|
||||
editor.setDecorations(this.normalModeLineDecoration, editor.selections)
|
||||
}
|
||||
|
||||
return vscode.commands.executeCommand('setContext', extensionName + '.mode', mode)
|
||||
if (vscode.window.activeTextEditor === editor)
|
||||
return this.onActiveModeChanged(mode)
|
||||
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
setMode(mode: Mode): Thenable<void> {
|
||||
setMode(mode: Mode) {
|
||||
const editor = vscode.window.activeTextEditor
|
||||
|
||||
return editor === undefined
|
||||
@ -98,6 +101,15 @@ export class Extension implements vscode.Disposable {
|
||||
: this.setEditorMode(editor, mode)
|
||||
}
|
||||
|
||||
private async onActiveModeChanged(mode: Mode) {
|
||||
if (mode === Mode.Insert)
|
||||
await vscode.workspace.getConfiguration('editor').update('lineNumbers', 'on')
|
||||
else if (mode === Mode.Normal)
|
||||
await vscode.workspace.getConfiguration('editor').update('lineNumbers', 'relative')
|
||||
|
||||
await vscode.commands.executeCommand('setContext', extensionName + '.mode', mode)
|
||||
}
|
||||
|
||||
setEnabled(enabled: boolean) {
|
||||
if (enabled === this.enabled)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user