Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Jun 18, 2018
2 parents 898cf57 + 0ffc087 commit 8332a7e
Show file tree
Hide file tree
Showing 35 changed files with 531 additions and 494 deletions.
36 changes: 34 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
# Change Log

## [v0.12.0](https://github.com/vscodevim/vim/tree/HEAD)
[Full Changelog](https://github.com/vscodevim/vim/compare/v0.11.6...HEAD)
## [v0.13.0](https://github.com/vscodevim/vim/tree/HEAD)

[Full Changelog](https://github.com/vscodevim/vim/compare/v0.12.0...HEAD)

- **Breaking Change**: We have removed `otherModesKeyBindings` configuration. In its stead we have added: `normalModeKeyBindings` and `visualModeKeyBidnings` to allow more fine-grain customization of your remappings. For more information, see our [documentation](https://github.com/vscodevim/vim#viminsertmodekeybindingsvimnormalmodekeybindingsvimvisualmodekeybindings).
- fix: handle when commandLineHistory is empty [\#2741](https://github.com/VSCodeVim/Vim/pull/2741) ([jpoon](https://github.com/jpoon))
- chore\(deps\): update dependency @types/node to v9.6.22 [\#2739](https://github.com/VSCodeVim/Vim/pull/2739) ([renovate-bot](https://github.com/renovate-bot))
- fix: use explicit configuration for logginglevel [\#2738](https://github.com/VSCodeVim/Vim/pull/2738) ([jpoon](https://github.com/jpoon))
- fix: remove duplicate UT [\#2734](https://github.com/VSCodeVim/Vim/pull/2734) ([jpoon](https://github.com/jpoon))
- Don't ignore mocked configurations' remaps during testing. [\#2733](https://github.com/VSCodeVim/Vim/pull/2733) ([regiontog](https://github.com/regiontog))
- chore\(deps\): update dependency typescript to v2.9.2 [\#2730](https://github.com/VSCodeVim/Vim/pull/2730) ([renovate-bot](https://github.com/renovate-bot))
- Fix autoindent on cc/S \#2497 [\#2729](https://github.com/VSCodeVim/Vim/pull/2729) ([dqsully](https://github.com/dqsully))
- Add normalModeKeyBindings and visualModeKeyBindings, remove otherModesKeyBindings [\#2726](https://github.com/VSCodeVim/Vim/pull/2726) ([chibicode](https://github.com/chibicode))
- chore\(deps\): update dependency @types/mocha to v5.2.2 [\#2724](https://github.com/VSCodeVim/Vim/pull/2724) ([renovate-bot](https://github.com/renovate-bot))
- fix: revert our workaround cursor toggle as this has been fixed in vscode [\#2720](https://github.com/VSCodeVim/Vim/pull/2720) ([jpoon](https://github.com/jpoon))
- feat: use winston for logging [\#2719](https://github.com/VSCodeVim/Vim/pull/2719) ([jpoon](https://github.com/jpoon))
- chore\(deps\): update dependency prettier to v1.13.5 [\#2718](https://github.com/VSCodeVim/Vim/pull/2718) ([renovate-bot](https://github.com/renovate-bot))
- chore\(deps\): update dependency @types/node to v9.6.21 [\#2715](https://github.com/VSCodeVim/Vim/pull/2715) ([renovate-bot](https://github.com/renovate-bot))
- Update prettier dependency [\#2712](https://github.com/VSCodeVim/Vim/pull/2712) ([xconverge](https://github.com/xconverge))
- chore\(deps\): update dependency @types/mocha to v5.2.1 [\#2704](https://github.com/VSCodeVim/Vim/pull/2704) ([renovate-bot](https://github.com/renovate-bot))
- fix gf to be like issue \#2683 [\#2701](https://github.com/VSCodeVim/Vim/pull/2701) ([SuyogSoti](https://github.com/SuyogSoti))
- chore\(deps\): update dependency typescript to v2.9.1 [\#2698](https://github.com/VSCodeVim/Vim/pull/2698) ([renovate-bot](https://github.com/renovate-bot))
- Fix vim-commentary description in README [\#2694](https://github.com/VSCodeVim/Vim/pull/2694) ([Ran4](https://github.com/Ran4))
- chore\(deps\): update dependency @types/node to v9.6.20 [\#2691](https://github.com/VSCodeVim/Vim/pull/2691) ([renovate-bot](https://github.com/renovate-bot))
- fix: fix 'no-use-before-declare' requires type information lint warning [\#2679](https://github.com/VSCodeVim/Vim/pull/2679) ([jpoon](https://github.com/jpoon))
- chore\(deps\): update dependency gulp-git to v2.7.0 [\#2678](https://github.com/VSCodeVim/Vim/pull/2678) ([renovate-bot](https://github.com/renovate-bot))
- chore\(deps\): update dependency vscode to v1.1.18 [\#2676](https://github.com/VSCodeVim/Vim/pull/2676) ([renovate-bot](https://github.com/renovate-bot))
- Fixed difference in behavior for \]\) and \]} when combined with certain operators [\#2671](https://github.com/VSCodeVim/Vim/pull/2671) ([willcassella](https://github.com/willcassella))
- fix\(deps\): update dependency untildify to v3.0.3 [\#2669](https://github.com/VSCodeVim/Vim/pull/2669) ([renovate-bot](https://github.com/renovate-bot))
- chore\(deps\): update dependency mocha to v5.2.0 [\#2666](https://github.com/VSCodeVim/Vim/pull/2666) ([renovate-bot](https://github.com/renovate-bot))
- chore\(deps\): update dependency @types/node to v9.6.16 [\#2644](https://github.com/VSCodeVim/Vim/pull/2644) ([renovate-bot](https://github.com/renovate-bot))

## [v0.12.0](https://github.com/vscodevim/vim/tree/v0.12.0) (2018-05-16)
[Full Changelog](https://github.com/vscodevim/vim/compare/v0.11.6...v0.12.0)

- Fix development problems on win [\#2651](https://github.com/VSCodeVim/Vim/pull/2651) ([KamikazeZirou](https://github.com/KamikazeZirou))
- Fixes \#2632 [\#2641](https://github.com/VSCodeVim/Vim/pull/2641) ([xconverge](https://github.com/xconverge))
Expand Down
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ Below is an example of a [settings.json](https://code.visualstudio.com/Docs/cust
"after": ["<Esc>"]
}
],
"vim.otherModesKeyBindingsNonRecursive": [
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>","d"],
"after": ["d", "d"]
},
{
"before":["<C-n>"],
"after":[],
"commands": [
{
"command": ":nohl"
Expand Down Expand Up @@ -207,15 +206,11 @@ These settings are specific to VSCodeVim.
* This setting can be changed through the settings or via `toggleVim` command in the Command Palette
* Type: Boolean (Default: `false`)

#### `"vim.debug"`
#### `"vim.debug.loggingLevel"`

* If the extension is giving you issues, toggle some settings here to provide more verbose debugging information

```json
"vim.debug": {
"loggingLevel": "error"
},
```
* Extension logging level. Maximum level of messages to log.
* Logs will be visible in the [developer tools](https://code.visualstudio.com/docs/extensions/developing-extensions#_profiling-your-extension).
* Type: String (Default: 'error'). Supported values: 'error', 'warn', 'info', 'verbose', 'debug'.

### Neovim Integration

Expand All @@ -241,9 +236,9 @@ Here's some ideas on what you can do with neovim integration:

There's several different mechanisms you can use to define custom remappings. Also see the [`useCtrlKeys`](#vimusectrlkeys) and [`handleKeys`](#vimhandlekeys) settings.

#### `"vim.insertModeKeyBindings"`/`"vim.otherModesKeyBindings"`
#### `"vim.insertModeKeyBindings"`/`"vim.normalModeKeyBindings"`/`"vim.visualModeKeyBindings"`

* Keybinding overrides to use for insert and other (non-insert) modes.
* Keybinding overrides to use for insert, normal, and visual modes.
* Bind `jj` to `<Esc>` in insert mode:

```json
Expand All @@ -258,10 +253,9 @@ There's several different mechanisms you can use to define custom remappings. Al
* Bind `:` to show the command palette:

```json
"vim.otherModesKeyBindingsNonRecursive": [
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [":"],
"after": [],
"commands": [
{
"command": "workbench.action.showCommands",
Expand All @@ -275,10 +269,9 @@ There's several different mechanisms you can use to define custom remappings. Al
* Bind `ZZ` to the vim command `:wq` (save and close the current file):

```json
"vim.otherModesKeyBindingsNonRecursive": [
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["Z", "Z"],
"after": [],
"commands": [
{
"command": ":wq",
Expand All @@ -292,10 +285,9 @@ There's several different mechanisms you can use to define custom remappings. Al
* Bind `ctrl+n` to turn off search highlighting and `<leader>w` to save the current file:

```json
"vim.otherModesKeyBindingsNonRecursive": [
"vim.normalModeKeyBindingsNonRecursive": [
{
"before":["<C-n>"],
"after":[],
"commands": [
{
"command": ":nohl",
Expand All @@ -305,7 +297,6 @@ There's several different mechanisms you can use to define custom remappings. Al
},
{
"before": ["leader", "w"],
"after": [],
"commands": [
{
"command": "workbench.action.files.save",
Expand All @@ -316,13 +307,62 @@ There's several different mechanisms you can use to define custom remappings. Al
]
```

#### `"vim.insertModeKeyBindingsNonRecursive"`/`"otherModesKeyBindingsNonRecursive"`
* Bind `p` in visual mode to paste without overriding the current register

```json
"vim.visualModeKeyBindingsNonRecursive": [
{
"after": [
"\"",
"_",
"d",
"P"
],
"before": [
"p",
]
}
],
```

* Bind `>` and `<` in visual mode to indent/outdent lines (repeatable)


```json
"vim.visualModeKeyBindingsNonRecursive": [
{
"before": [
">"
],
"commands": [
{
"args": [],
"command": "editor.action.indentLines"
}
]
},
{
"before": [
"<"
],
"commands": [
{
"args": [],
"command": "editor.action.outdentLines"
}
]
},
]
```


#### `"vim.insertModeKeyBindingsNonRecursive"`/`"normalModeKeyBindingsNonRecursive"`/`"visualModeKeyBindingsNonRecursive"`

* Non-recursive keybinding overrides to use for insert and other (non-insert) modes (similar to `:noremap`)
* *Example:* Bind `j` to `gj`. Notice that if you attempted this binding normally, the j in gj would be expanded into gj, on and on forever. Stop this recursive expansion using insertModeKeyBindingsNonRecursive and/or otherModesKeyBindingNonRecursive.
* Non-recursive keybinding overrides to use for insert, normal, and visual modes
* *Example:* Bind `j` to `gj`. Notice that if you attempted this binding normally, the j in gj would be expanded into gj, on and on forever. Stop this recursive expansion using insertModeKeyBindingsNonRecursive and/or normalModeKeyBindingNonRecursive.

```json
"vim.otherModesKeyBindingsNonRecursive": [
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["j"],
"after": ["g", "j"]
Expand Down
108 changes: 51 additions & 57 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import './src/actions/include-all';
import * as _ from 'lodash';
import * as vscode from 'vscode';

import { CommandLine } from './src/cmd_line/commandLine';
import { Position } from './src/common/motion/position';
import { configuration } from './src/configuration/configuration';
import { commandLine } from './src/cmd_line/commandLine';
import { Position } from './src/common/motion/position';
import { EditorIdentity } from './src/editorIdentity';
import { Globals } from './src/globals';
import { ModeName } from './src/mode/mode';
Expand Down Expand Up @@ -66,34 +66,25 @@ export async function getAndUpdateModeHandler(): Promise<ModeHandler> {
prevHandler!.vimState.focusChanged = true;
}

// Temporary workaround for vscode bug not changing cursor style properly
// https://github.com/Microsoft/vscode/issues/17472
// https://github.com/Microsoft/vscode/issues/17513
if (curHandler.vimState.editor) {
const desiredStyle = curHandler.vimState.editor.options.cursorStyle;

// Temporarily change to any other cursor style besides the desired type, then change back
let tempStyle = ((desiredStyle || vscode.TextEditorCursorStyle.Line) % 6) + 1;
curHandler.vimState.editor.options.cursorStyle = tempStyle;
curHandler.vimState.editor.options.cursorStyle = desiredStyle;
}

return curHandler;
}

export async function activate(context: vscode.ExtensionContext) {
logger.debug('Extension: activating vscodevim.');

extensionContext = context;
let compositionState = new CompositionState();

extensionContext.subscriptions.push(StatusBar);

logger.debug('Extension: registering event handlers.');

// workspace events
vscode.workspace.onDidChangeConfiguration(() => {
logger.debug('onDidChangeConfiguration: reloading configuration');
configuration.reload();
});

vscode.window.onDidChangeActiveTextEditor(handleActiveEditorChange, this);

vscode.workspace.onDidChangeTextDocument(event => {
if (configuration.disableExt) {
return;
Expand Down Expand Up @@ -131,6 +122,27 @@ export async function activate(context: vscode.ExtensionContext) {
}, 0);
});

vscode.workspace.onDidCloseTextDocument(async () => {
const documents = vscode.workspace.textDocuments;

// Delete modehandler once all tabs of this document have been closed
for (let editorIdentity of ModeHandlerMap.getKeys()) {
let modeHandler = await ModeHandlerMap.get(editorIdentity);

if (
modeHandler == null ||
modeHandler.vimState.editor === undefined ||
documents.indexOf(modeHandler.vimState.editor.document) === -1
) {
ModeHandlerMap.delete(editorIdentity);
}
}
});

// window events
vscode.window.onDidChangeActiveTextEditor(handleActiveEditorChange, this);

// override vscode commands
overrideCommand(context, 'type', async args => {
taskQueue.enqueueTask(async () => {
const mh = await getAndUpdateModeHandler();
Expand Down Expand Up @@ -183,11 +195,12 @@ export async function activate(context: vscode.ExtensionContext) {
});
});

// register extension commands
registerCommand(context, 'extension.showCmdLine', async () => {
let [modeHandler] = await ModeHandlerMap.getOrCreate(
new EditorIdentity(vscode.window.activeTextEditor).toString()
);
CommandLine.PromptAndRun('', modeHandler.vimState);
commandLine.PromptAndRun('', modeHandler.vimState);
modeHandler.updateView(modeHandler.vimState);
});

Expand All @@ -205,7 +218,7 @@ export async function activate(context: vscode.ExtensionContext) {
for (const command of args.commands) {
// Check if this is a vim command by looking for :
if (command.command.slice(0, 1) === ':') {
await CommandLine.Run(command.command.slice(1, command.command.length), mh.vimState);
await commandLine.Run(command.command.slice(1, command.command.length), mh.vimState);
await mh.updateView(mh.vimState);
} else {
await vscode.commands.executeCommand(command.command, command.args);
Expand All @@ -215,46 +228,9 @@ export async function activate(context: vscode.ExtensionContext) {
});
});

vscode.workspace.onDidCloseTextDocument(async () => {
const documents = vscode.workspace.textDocuments;

// Delete modehandler once all tabs of this document have been closed
for (let editorIdentity of ModeHandlerMap.getKeys()) {
let modeHandler = await ModeHandlerMap.get(editorIdentity);

if (
modeHandler == null ||
modeHandler.vimState.editor === undefined ||
documents.indexOf(modeHandler.vimState.editor.document) === -1
) {
ModeHandlerMap.delete(editorIdentity);
}
}
});

/**
* Toggles the VSCodeVim extension between Enabled mode and Disabled mode. This
* function is activated by calling the 'toggleVim' command from the Command Palette.
*
* @param isDisabled if true, sets VSCodeVim to Disabled mode; else sets to enabled mode
*/
async function toggleExtension(isDisabled: boolean) {
await vscode.commands.executeCommand('setContext', 'vim.active', !isDisabled);
let mh = await getAndUpdateModeHandler();
if (isDisabled) {
await mh.handleKeyEvent('<ExtensionDisable>');
compositionState.reset();
ModeHandlerMap.clear();
} else {
await mh.handleKeyEvent('<ExtensionEnable>');
}
}

CommandLine.LoadHistory();

registerCommand(context, 'toggleVim', async () => {
configuration.disableExt = !configuration.disableExt;
toggleExtension(configuration.disableExt);
toggleExtension(configuration.disableExt, compositionState);
});

for (const boundKey of configuration.boundKeyCombinations) {
Expand All @@ -268,7 +244,25 @@ export async function activate(context: vscode.ExtensionContext) {
}

// This is called last because getAndUpdateModeHandler() will change cursor
toggleExtension(configuration.disableExt);
toggleExtension(configuration.disableExt, compositionState);
}

/**
* Toggles the VSCodeVim extension between Enabled mode and Disabled mode. This
* function is activated by calling the 'toggleVim' command from the Command Palette.
*
* @param isDisabled if true, sets VSCodeVim to Disabled mode; else sets to enabled mode
*/
async function toggleExtension(isDisabled: boolean, compositionState: CompositionState) {
await vscode.commands.executeCommand('setContext', 'vim.active', !isDisabled);
let mh = await getAndUpdateModeHandler();
if (isDisabled) {
await mh.handleKeyEvent('<ExtensionDisable>');
compositionState.reset();
ModeHandlerMap.clear();
} else {
await mh.handleKeyEvent('<ExtensionEnable>');
}
}

function overrideCommand(
Expand Down
Loading

0 comments on commit 8332a7e

Please sign in to comment.