Skip to content

Commit

Permalink
Merge pull request #50 from aioutecism/feature/new-api-support
Browse files Browse the repository at this point in the history
Switch to new VSCode APIs
  • Loading branch information
aioutecism committed Mar 17, 2016
2 parents cce5d48 + 8d11fa9 commit b469d36
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 397 deletions.
33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Beta
# Evolution

This extension is in beta state. Functions may have bugs, but they will be fixed soon.
Starting from "amVim 1.0.0", we are using some new APIs that are only avaliable from "VSCode 0.10.12".

Feel free to open [issues](https://github.com/aioutecism/amVim-for-VSCode/issues) to report bugs or require functions.
These APIs enable amVim to get rid of all anonying problems related to **intellisense, keyboard layout, etc.**.

"VSCode 0.10.12" is not released now. But you can get the insiders version [here]() and install amVim to feel the difference!


# amVim for VSCode
Expand All @@ -17,12 +19,14 @@ The [Vim](http://www.vim.org/) mode for [Visual Studio Code](https://code.visual
- Vim style keybindings & looks
- Normal, Visual and Visual Line modes support
- Multi-cursor support
- Works with VSCode's default behaviors


## Not supported

- `:` started commands: Please use `Command Palette` (`Shift+Cmd+P` on OSX, `Shift+Ctrl+P` on Windows) instead.
- Visual Block mode: Please use multi-cursor instead.
- Visual Block mode: Please use multi-cursor instead for now.
- Custom keybindings: On the roadmap.


## Commands
Expand All @@ -35,28 +39,15 @@ Check the list [here](https://github.com/aioutecism/amVim-for-VSCode/issues/1).
You can overwrite default configurations in
[User and Workspace Settings](https://code.visualstudio.com/docs/customization/userandworkspace).

#### `amVim.keyboardLayout`

`String`, Default: `US QWERTY`

Your keyboard layout.

Values avaliable:

- `US QWERTY`
- `DE_CH QWERTZ`

**This won't be needed after VSCode v0.10.12 is released.**


#### `amVim.bindCtrlC`

`Boolean`, Default: `false`

Set to `true` to bind `Ctrl+C` as the same behaviour in Vim.


## Similar projects
## Contribution

Feel free to open [issues](https://github.com/aioutecism/amVim-for-VSCode/issues) to report bugs or require features.

- [74th/vscode-vim](https://github.com/74th/vscode-vim)
- [VSCodeVim/Vim](https://github.com/VSCodeVim/Vim)
[Pull requests](https://github.com/aioutecism/amVim-for-VSCode/pulls) are welcomed too!
Binary file modified images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 12 additions & 129 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "amvim",
"version": "0.1.7-pre",
"version": "1.0.0",
"publisher": "auiworks",
"icon": "images/icon.png",
"displayName": "amVim Beta",
"displayName": "amVim",
"description": "The Vim mode for Visual Studio Code that works as expected.",
"galleryBanner": {
"color": "#232323",
Expand All @@ -29,18 +29,13 @@
"author": "aioutecism",
"license": "ISC",
"engines": {
"vscode": "^0.10.10"
"vscode": "^0.10.12"
},
"main": "./out/src/extension",
"contributes": {
"configuration": {
"title": "amVim configuration",
"properties": {
"amVim.keyboardLayout": {
"type": "string",
"default": "US QWERTY",
"description": "Your keyboard layout.\nVisit project homepage to find out supported layouts or add your own!"
},
"amVim.bindCtrlC": {
"type": "boolean",
"default": false,
Expand All @@ -49,126 +44,14 @@
}
},
"keybindings": [
{ "command": "vim.a", "key": "a", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.b", "key": "b", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.c", "key": "c", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.d", "key": "d", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.e", "key": "e", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.f", "key": "f", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.g", "key": "g", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.h", "key": "h", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.i", "key": "i", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.j", "key": "j", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.k", "key": "k", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.l", "key": "l", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.m", "key": "m", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.n", "key": "n", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.o", "key": "o", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.p", "key": "p", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.q", "key": "q", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.r", "key": "r", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.s", "key": "s", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.t", "key": "t", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.u", "key": "u", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.v", "key": "v", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.w", "key": "w", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.x", "key": "x", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.y", "key": "y", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.z", "key": "z", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "amVim.backspace", "key": "backspace", "when": "editorTextFocus && amVim.mode != 'INSERT'" },
{ "command": "amVim.delete", "key": "delete", "when": "editorTextFocus && amVim.mode != 'INSERT'" },
{ "command": "amVim.escape", "key": "escape", "when": "editorTextFocus" },

{ "command": "vim.A", "key": "shift+a", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.B", "key": "shift+b", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.C", "key": "shift+c", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.D", "key": "shift+d", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.E", "key": "shift+e", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.F", "key": "shift+f", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.G", "key": "shift+g", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.H", "key": "shift+h", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.I", "key": "shift+i", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.J", "key": "shift+j", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.K", "key": "shift+k", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.L", "key": "shift+l", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.M", "key": "shift+m", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.N", "key": "shift+n", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.O", "key": "shift+o", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.P", "key": "shift+p", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.Q", "key": "shift+q", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.R", "key": "shift+r", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.S", "key": "shift+s", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.T", "key": "shift+t", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.U", "key": "shift+u", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.V", "key": "shift+v", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.W", "key": "shift+w", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.X", "key": "shift+x", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.Y", "key": "shift+y", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.Z", "key": "shift+z", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.1", "key": "1", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.2", "key": "2", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.3", "key": "3", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.4", "key": "4", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.5", "key": "5", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.6", "key": "6", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.7", "key": "7", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.8", "key": "8", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.9", "key": "9", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.0", "key": "0", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.shift+1", "key": "shift+1", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+2", "key": "shift+2", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+3", "key": "shift+3", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+4", "key": "shift+4", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+5", "key": "shift+5", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+6", "key": "shift+6", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+7", "key": "shift+7", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+8", "key": "shift+8", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+9", "key": "shift+9", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+0", "key": "shift+0", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.vk_oem_1", "key": ";", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_2", "key": "/", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_3", "key": "`", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_4", "key": "[", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_5", "key": "\\", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_6", "key": "]", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_7", "key": "'", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_102", "key": "oem_102", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.shift+vk_oem_1", "key": "shift+;", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_2", "key": "shift+/", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_3", "key": "shift+`", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_4", "key": "shift+[", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_5", "key": "shift+\\", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_6", "key": "shift+]", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_7", "key": "shift+'", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_102", "key": "shift+oem_102", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.vk_oem_minus", "key": "-", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_plus", "key": "=", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_comma", "key": ",", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.vk_oem_period", "key": ".", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.shift+vk_oem_minus", "key": "shift+-", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_plus", "key": "shift+=", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_comma", "key": "shift+,", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.shift+vk_oem_period", "key": "shift+.", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.space", "key": "space", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.enter", "key": "enter", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.tab", "key": "tab", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.backspace", "key": "backspace", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.delete", "key": "delete", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.escape", "key": "escape", "when": "editorTextFocus" },

{ "command": "vim.shift+enter", "key": "shift+enter", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.alt+b", "key": "alt+b", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.alt+w", "key": "alt+w", "when": "editorTextFocus && !suggestWidgetVisible" },

{ "command": "vim.ctrl+c", "key": "ctrl+c", "when": "editorTextFocus" },
{ "command": "vim.ctrl+r", "key": "ctrl+r", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.ctrl+u", "key": "ctrl+u", "when": "editorTextFocus && !suggestWidgetVisible" },
{ "command": "vim.ctrl+w", "key": "ctrl+w", "when": "editorTextFocus && !suggestWidgetVisible" }
{ "command": "amVim.ctrl+c", "key": "ctrl+c", "when": "editorTextFocus && amVim.configuration.shouldBindCtrlC" },
{ "command": "amVim.ctrl+r", "key": "ctrl+r", "when": "editorTextFocus && amVim.mode == 'NORMAL'" },
{ "command": "amVim.ctrl+u", "key": "ctrl+u", "when": "editorTextFocus && amVim.mode == 'INSERT'" },
{ "command": "amVim.ctrl+w", "key": "ctrl+w", "when": "editorTextFocus && amVim.mode == 'INSERT'" }
]
},
"activationEvents": [
Expand All @@ -180,7 +63,7 @@
"postinstall": "node ./node_modules/vscode/bin/install"
},
"devDependencies": {
"typescript": "^1.8.2",
"vscode": "^0.11.7"
"typescript": "^1.8.5",
"vscode": "^0.11.8"
}
}
4 changes: 0 additions & 4 deletions src/Actions/Insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {MotionLine} from '../Motions/Line';

export class ActionInsert {

static tabAtSelections(): Thenable<boolean> {
return commands.executeCommand('tab');
}

static lineBreakAtSelections(): Thenable<boolean> {
const activeTextEditor = window.activeTextEditor;

Expand Down
10 changes: 5 additions & 5 deletions src/Actions/Mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import {ModeID} from '../Modes/Mode';
export class ActionMode {

static toNormal(): Thenable<boolean> {
return commands.executeCommand(`vim.mode.${ModeID.NORMAL}`);
return commands.executeCommand(`amVim.mode.${ModeID.NORMAL}`);
}

static toVisual(): Thenable<boolean> {
return commands.executeCommand(`vim.mode.${ModeID.VISUAL}`);
return commands.executeCommand(`amVim.mode.${ModeID.VISUAL}`);
}

static toVisualLine(): Thenable<boolean> {
return commands.executeCommand(`vim.mode.${ModeID.VISUAL_LINE}`);
return commands.executeCommand(`amVim.mode.${ModeID.VISUAL_LINE}`);
}

static toInsert(): Thenable<boolean> {
return commands.executeCommand(`vim.mode.${ModeID.INSERT}`);
return commands.executeCommand(`amVim.mode.${ModeID.INSERT}`);
}

static switchByActiveSelections(currentMode: ModeID): Thenable<boolean> {
Expand Down Expand Up @@ -48,7 +48,7 @@ export class ActionMode {
return Promise.resolve(true);
}
else {
return commands.executeCommand(`vim.mode.${mode}`);
return commands.executeCommand(`amVim.mode.${mode}`);
}
}

Expand Down
14 changes: 0 additions & 14 deletions src/Actions/Suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@ import {Configuration} from '../Configuration';

export class ActionSuggestion {

static triggerCharacters = /[a-z0-9_,.(]/i;

static trigger(args: {key: string}): Thenable<boolean> {
// HACK: Work around lack of keybinding context API
if (! ActionSuggestion.triggerCharacters.test(args.key) ||
! Configuration.getEditorSetting('quickSuggestions')) {
return;
}

// TODO: Don't trigger suggest when no suggestion is available

return commands.executeCommand('editor.action.triggerSuggest');
}

static hide(): Thenable<boolean> {
return commands.executeCommand('hideSuggestWidget');
}
Expand Down
18 changes: 6 additions & 12 deletions src/Configuration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {workspace, WorkspaceConfiguration, Disposable} from 'vscode';
import {Layout} from './Layouts/Layout';
import {commands, workspace, WorkspaceConfiguration, Disposable} from 'vscode';

export class Configuration {

private static defaultKeyboardLayout = 'US QWERTY';

private static isReady = false;
private static extensionNamespace: WorkspaceConfiguration;
private static editorNamespace: WorkspaceConfiguration;
Expand All @@ -18,12 +15,12 @@ export class Configuration {
this.isReady = true;

this.updateCache();
this.updateLayout();
this.updateKeybindingContexts();

this.disposables.push(
workspace.onDidChangeConfiguration(() => {
this.updateCache();
this.updateLayout();
this.updateKeybindingContexts();
})
);
}
Expand All @@ -33,12 +30,9 @@ export class Configuration {
this.editorNamespace = workspace.getConfiguration('editor');
}

private static updateLayout(): void {
try {
Layout.use(this.getExtensionSetting<string>('keyboardLayout'));
} catch (error) {
Layout.use(this.defaultKeyboardLayout);
}
private static updateKeybindingContexts(): void {
commands.executeCommand('setContext',
'amVim.configuration.shouldBindCtrlC', this.getExtensionSetting<boolean>('bindCtrlC'));
}

static getExtensionSetting<T>(section: string, defaultValue?: T): T {
Expand Down
Loading

0 comments on commit b469d36

Please sign in to comment.