Skip to content

Commit

Permalink
Merged upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatRendle committed Dec 2, 2015
2 parents 4a4d073 + 9c01d76 commit cb53e3a
Show file tree
Hide file tree
Showing 38 changed files with 1,152 additions and 309 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ language: node_js
node_js:
- "4.1.1"

env:
- TSD_GITHUB_TOKEN=8742b29e67faa29aa25564ff7317b50fd7c1327d

install:
- npm install
before_script:
Expand Down
56 changes: 29 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[![Build Status](https://travis-ci.org/VSCodeVim/Vim.svg?branch=master)](https://travis-ci.org/VSCodeVim/Vim) [![Build status](https://ci.appveyor.com/api/projects/status/0t6ljij7g5h0ddx8?svg=true)](https://ci.appveyor.com/project/guillermooo/vim) [![Slack Status](http://slackin.westus.cloudapp.azure.com/badge.svg)](http://slackin.westus.cloudapp.azure.com)

# Vim

Vim emulation for Visual Studio Code.
[![Build Status](https://travis-ci.org/VSCodeVim/Vim.svg?branch=master)](https://travis-ci.org/VSCodeVim/Vim) [![Build status](https://ci.appveyor.com/api/projects/status/0t6ljij7g5h0ddx8?svg=true)](https://ci.appveyor.com/project/guillermooo/vim) [![Slack Status](http://slackin.westus.cloudapp.azure.com/badge.svg)](http://slackin.westus.cloudapp.azure.com)

Vim (aka. VSCodeVim) is a [Visual Studio Code](https://code.visualstudio.com/) extension that enabling the use of the Vim keybinding experience within Visual Studio Code.

![Screenshot](images/screen.png)

## Installation
## Install

1. Install [Visual Studio Code](https://code.visualstudio.com/)
2. Open the command palette (`Ctrl-Shift-P` or `Cmd-Shift-P`) select `Install Extension` and search for **vim**. Alternatively, run `ext install vim`
1. Within Visual Studio Code, open the command palette (`Ctrl-Shift-P` / `Cmd-Shift-P`)
2. Select `Install Extension` and search for 'vim' *or* run `ext install vim`

## Project Status

See our [release notes](https://github.com/VSCodeVim/Vim/releases) for full details.

### Completed

* Modes:
Expand All @@ -23,40 +25,40 @@ Vim emulation for Visual Studio Code.

* Commands:
* Command Palette: `:`
* Navigation: `h`, `j`, `k`, `l`
* Navigation: `h`, `j`, `k`, `l`, `w`, `b`, `gg`, `G`
* Indentation: `>>`, `<<`
* Deletion: `dd`, `dw`, `db`
* Editing: `u`, `ctrl+r`
* File Operations: `:q`, `:w`

### Planned
## Contributing

In no particular order:
Contributions are extremely welcomed!
Take a look at [Extension API](https://code.visualstudio.com/docs/extensionAPI/overview) on how to get started and our current [issues](https://github.com/VSCodeVim/Vim/issues) to see what we are working on next.

* Search: `/`
* Support Macros
* Buffers
* Neovim Integration
### Developing

## Contributions
1. Install prerequisites:
* latest [Visual Studio Code](https://code.visualstudio.com/)
* [Node.js](https://nodejs.org/) v4.0.0 or higher
2. Fork and clone the repo, then

Contributions are extremely welcomed!
Take a look at [Extension API](https://code.visualstudio.com/docs/extensionAPI/overview) on how to get started and our current [issues](https://github.com/VSCodeVim/Vim/issues) to see what we are working on next.
```bash
$ npm install
$ npm install -g gulp
$ gulp init
```

3. Open the folder in VS Code

#### Submitting a PR

### Getting started
You've made some changes, and you are ready to submit a PR? Please make sure:

1. Install [Visual Studio Code](https://code.visualstudio.com/).
2. Install [Node.js](https://nodejs.org/) with version > 4.0.0.
3. Fork the repo.
4. `npm install`
5. `gulp init`
* This step will install type definitions (using [tsd](http://definitelytyped.org/tsd/)).
6. Create a topic branch.
7. Ensure tests pass:
1. Tests pass:
* `gulp`: run tslint and tests
* [Launch tests within VS Code](https://code.visualstudio.com/docs/extensions/testing-extensions)
8. Squash your commits.
9. Submit your PR.
2. Commits are squashed

## License

Expand Down
5 changes: 2 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
environment:
node_js_version: "4.1.1"
TSD_GITHUB_TOKEN: "4c7f278997af83ba584aaa9c5722d5ecbbcb1dd9"

clone_depth: 1
TSD_GITHUB_TOKEN: "8742b29e67faa29aa25564ff7317b50fd7c1327d"
clone_depth: 1

install:
- ps: start-filedownload https://az764295.vo.msecnd.net/public/0.10.1-release/VSCode-win32.zip
Expand Down
10 changes: 6 additions & 4 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {showCmdLine} from './src/cmd_line/main';
import * as cc from './src/cmd_line/lexer';
import ModeHandler from "./src/mode/modeHandler";
import {ModeName} from "./src/mode/mode";
import Cursor from "./src/cursor";
import Cursor from "./src/cursor/cursor";

var modeHandler : ModeHandler;

Expand Down Expand Up @@ -87,16 +87,18 @@ export function activate(context: vscode.ExtensionContext) {
registerCommand(context, 'extension.vim_6', () => handleKeyEvent("6"));
registerCommand(context, 'extension.vim_7', () => handleKeyEvent("7"));
registerCommand(context, 'extension.vim_8', () => handleKeyEvent("8"));
registerCommand(context, 'extension.vim_9', () => handleKeyEvent("9"));
registerCommand(context, 'extension.vim_9', () => handleKeyEvent("9"));

registerCommand(context, 'extension.vim_$', () => handleKeyEvent("$"));
registerCommand(context, 'extension.vim_^', () => handleKeyEvent("^"));

registerCommand(context, 'extension.vim_ctrl_r', () => handleKeyEvent("ctrl+r"));
registerCommand(context, 'extension.vim_ctrl_[', () => handleKeyEvent("ctrl+["));

registerCommand(context, 'extension.vim_<', () => handleKeyEvent("<"));
registerCommand(context, 'extension.vim_>', () => handleKeyEvent(">"));

registerCommand(context, 'extension.vim_backslash', () => handleKeyEvent("\\"));
}

function registerCommand(context: vscode.ExtensionContext, command: string, callback: (...args: any[]) => any) {
Expand All @@ -106,4 +108,4 @@ function registerCommand(context: vscode.ExtensionContext, command: string, call

function handleKeyEvent(key:string) {
modeHandler.handleKeyEvent(key);
}
}
25 changes: 17 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var gulp = require('gulp');
var tslint = require('gulp-tslint');
var tsd = require('gulp-tsd');
var shell = require('gulp-shell');
var mocha = require('gulp-mocha');
var gulp = require('gulp'),
tslint = require('gulp-tslint'),
tsd = require('gulp-tsd'),
shell = require('gulp-shell'),
mocha = require('gulp-mocha'),
trimlines = require('gulp-trimlines');

var paths = {
scripts_ts: "src/**/*.ts",
Expand All @@ -21,11 +22,19 @@ gulp.task('tsd', function (callback) {
}, callback));
});

gulp.task('compile', shell.task([
gulp.task('trim-whitespace', function() {
return gulp.src([paths.scripts_ts, paths.tests_ts], { base: "./" })
.pipe(trimlines({
leading: false
}))
.pipe(gulp.dest('./'));
});

gulp.task('compile', ['trim-whitespace'], shell.task([
'node ./node_modules/vscode/bin/compile -p ./',
]));

gulp.task('tslint', function() {
gulp.task('tslint', ['trim-whitespace'], function() {
return gulp.src([paths.scripts_ts, paths.tests_ts])
.pipe(tslint())
.pipe(tslint.report('prose', {
Expand All @@ -44,4 +53,4 @@ gulp.task('test', ['compile'], function () {
});

gulp.task('init', ['tsd']);
gulp.task('default', ['tslint', 'test']);
gulp.task('default', ['trim-whitespace', 'tslint', 'test']);
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
{ "key": "Shift+;", "command": "extension.vim_colon", "when": "editorTextFocus" },
{ "key": ":", "command": "extension.vim_colon", "when": "editorTextFocus" },
{ "key": "space", "command": "extension.vim_space", "when": "editorTextFocus" },
{ "key": "\\", "command": "extension.vim_backslash", "when": "editorTextFocus" },

{ "key": "a", "command": "extension.vim_a", "when": "editorTextFocus" },
{ "key": "b", "command": "extension.vim_b", "when": "editorTextFocus" },
Expand Down Expand Up @@ -120,8 +121,18 @@

{ "key": "Shift+,", "command": "extension.vim_<", "when": "editorTextFocus" },
{ "key": "Shift+.", "command": "extension.vim_>", "when": "editorTextFocus" }

]
],
"configuration": {
"title": "Vim Configuration",
"type": "object",
"properties": {
"vim.keyboardLayout": {
"default": "en-US (QWERTY)",
"type": "string",
"description": "Keyboard layout to use to translated key presses."
}
}
}
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
Expand All @@ -133,6 +144,7 @@
"gulp-shell": "^0.5.1",
"gulp-tsd": "0.0.4",
"gulp-tslint": "^3.6.0",
"gulp-trimlines": "^1.0.0",
"gulp-typescript": "^2.9.2",
"tsd": "^0.6.5",
"typescript": "^1.6.2",
Expand Down
8 changes: 4 additions & 4 deletions src/cmd_line/commands/quit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ export class QuitCommand extends node.CommandBase {
this._shortName = 'q';
this._arguments = args;
}

get arguments() : QuitCommandArguments {
return this._arguments;
}

execute() : void {
this.quit();
}
}

private quit() {
// See https://github.com/Microsoft/vscode/issues/723
if ((this.activeTextEditor.document.isDirty || this.activeTextEditor.document.isUntitled)
&& !this.arguments.bang) {
throw error.VimError.fromCode(error.ErrorCode.E37);
}

vscode.commands.executeCommand('workbench.action.closeActiveEditor');
};
}
10 changes: 5 additions & 5 deletions src/cmd_line/commands/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class WriteCommand extends node.CommandBase {
this._shortName = 'w';
this._arguments = args;
}

get arguments() : WriteCommandArguments {
return this._arguments;
}
Expand All @@ -47,10 +47,10 @@ export class WriteCommand extends node.CommandBase {
util.showError("Not implemented.");
return;
}

if (this.activeTextEditor.document.isUntitled) {
throw error.VimError.fromCode(error.ErrorCode.E32);
}
}

fs.access(this.activeTextEditor.document.fileName, fs.W_OK, (accessErr) => {
if (accessErr) {
Expand All @@ -71,7 +71,7 @@ export class WriteCommand extends node.CommandBase {
});
}

private save() {
private save() {
this.activeTextEditor.document.save().then(
(ok) => {
if (ok) {
Expand All @@ -82,5 +82,5 @@ export class WriteCommand extends node.CommandBase {
},
(e) => util.showError(e)
);
}
}
}
10 changes: 5 additions & 5 deletions src/cmd_line/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function showCmdLine(initialText = "") {
util.showInfo("No active document.");
return;
}

const options : vscode.InputBoxOptions = {
prompt: "Vim command line",
value: initialText
Expand All @@ -23,14 +23,14 @@ function runCmdLine(s : string) : void {
if (!(s && s.trim())) {
return;
}

try {
var cmd = parser.parse(s);
} catch (e) {
util.showError(e);
return;
}

if (cmd.isEmpty) {
return;
}
Expand All @@ -44,7 +44,7 @@ function runCmdLine(s : string) : void {
} catch (ee) {
// ignore
}
util.showError(e);

util.showError(e);
}
}
10 changes: 5 additions & 5 deletions src/cmd_line/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ export interface CommandArgs {
}

export abstract class CommandBase {

protected get activeTextEditor() {
return vscode.window.activeTextEditor;
}

get name() : string {
return this._name;
}
protected _name : string;

get shortName() : string {
return this._shortName;
}
Expand All @@ -119,7 +119,7 @@ export abstract class CommandBase {
get arguments() : CommandArgs {
return this._arguments;
}
protected _arguments : CommandArgs;
protected _arguments : CommandArgs;

abstract execute() : void;
}
4 changes: 2 additions & 2 deletions src/cmd_line/subparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {parseWriteCommandArgs} from './subparsers/write';

// TODO: add type for this dict.
// maps command names to parsers for said commands.
export const commandParsers = {
export const commandParsers = {
'w': parseWriteCommandArgs,
'write': parseWriteCommandArgs,

'quit': parseQuitCommandArgs,
'q': parseQuitCommandArgs
};
15 changes: 15 additions & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {KeyboardLayout} from "./keyboard";

export default class Configuration {

keyboardLayout : KeyboardLayout;

constructor(keyboard : KeyboardLayout) {
this.keyboardLayout = keyboard;
}

static fromUserFile() {
// TODO: read .vimrc or a similar file.
return new Configuration(KeyboardLayout.fromUserConfiguration());
}
}
Loading

0 comments on commit cb53e3a

Please sign in to comment.