Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Add Normal, Visual and Visual Line modes #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.browser_modules
lib
*.log
*-app/*
!*-app/package.json
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Browser Backend",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/browser-app/lib/**/*.js",
"${workspaceRoot}/browser-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/electron-app/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
115 changes: 115 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Vi Extension
The example of how to build the Theia-based applications with the Vi-extension.

## Getting started

Install [nvm](https://github.com/creationix/nvm#install-script).

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash

Install npm and node.

nvm install 8
nvm use 8

Install yarn.

npm install -g yarn

## Running the browser example

yarn rebuild:browser
cd browser-app
yarn start

Open http://localhost:3000 in the browser.

## Running the Electron example

yarn rebuild:electron
cd electron-app
yarn start

## Developing with the browser example

Start watching of the vi extension.

cd vi-extension
yarn watch

Start watching of the browser example.

yarn rebuild:browser
cd browser-app
yarn watch

Launch `Start Browser Backend` configuration from VS code.

Open http://localhost:3000 in the browser.

## Developing with the Electron example

Start watching of the vi-extension.

cd vi-extension
yarn watch

Start watching of the electron example.

yarn rebuild:electron
cd electron-app
yarn watch

Launch `Start Electron Backend` configuration from VS code.

## Publishing vi-extension

Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).

npm login

Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).

npx lerna publish

### Insert Mode
|Command | Desc |
|----------------|----------------------------------------------------------------------------------------|
| `a` | Moves the cursor after the current character and enters insert mode |
| `A` | Moves the cursor to the end of the line and enters insert mode |
| `i (ins)` | Switches to insert mode |
| `I` | Moves the cursor to the beginning of the line and enters insert mode |
| `o` | Inserts a new line below the current line and enters insert mode on the new line |
| `O` | Inserts a new line above the current one and enters insert mode on the new line |

### Normal Mode
|Command | Desc |
|----------------|----------------------------------------------------------------------------------------|
| `esc (ctrl-[)` | enter Normal Mode |
| `l (right)` | Move forward |
| `h (left)` | Move backward |
| `j (down)` | Move to the next line |
| `k (up)` | Move to the previous line |
| `0` | Move to the beginning of line |
| `$` | Move to the end of line |
| `b` | Move to previous beginning of word |
| `e` | Move to end of word |

### Visual Mode
|Command | Desc |
|----------------|----------------------------------------------------------------------------------------|
| `v` | enter Visual Mode, this will also mark a starting selection point |
| `l (right)` | Select forward |
| `h (left)` | Select backward |
| `k (up)` | Select up |
| `j (down)` | Select down |

Move the cursor to the desired end selection point; vi will provide a visual highlight of the text selection

### Visual Line Mode
|Command | Desc |
|----------------|----------------------------------------------------------------------------------------|
| `V` | select current line and enter Visual Line Mode, this will make text selections by line |
| `k (up)` | select line up |
| `j (down)` | select line down |
| `d` | delete selected lines |
33 changes: 33 additions & 0 deletions browser-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"private": true,
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "0.3.12",
"@theia/filesystem": "0.3.12",
"@theia/file-search": "0.3.12",
"@theia/workspace": "0.3.12",
"@theia/preferences": "0.3.12",
"@theia/navigator": "0.3.12",
"@theia/process": "0.3.12",
"@theia/terminal": "0.3.12",
"@theia/editor": "0.3.12",
"@theia/languages": "0.3.12",
"@theia/markers": "0.3.12",
"@theia/monaco": "0.3.12",
"@theia/typescript": "0.3.12",
"@theia/messages": "0.3.12",
"vi-extension": "0.0.0"
},
"devDependencies": {
"@theia/cli": "0.3.12"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "browser"
}
}
33 changes: 33 additions & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"private": true,
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "0.3.12",
"@theia/filesystem": "0.3.12",
"@theia/file-search": "0.3.12",
"@theia/workspace": "0.3.12",
"@theia/preferences": "0.3.12",
"@theia/navigator": "0.3.12",
"@theia/process": "0.3.12",
"@theia/terminal": "0.3.12",
"@theia/editor": "0.3.12",
"@theia/languages": "0.3.12",
"@theia/markers": "0.3.12",
"@theia/monaco": "0.3.12",
"@theia/typescript": "0.3.12",
"@theia/messages": "0.3.12",
"vi-extension": "0.0.0"
},
"devDependencies": {
"@theia/cli": "0.3.12"
},
"scripts": {
"prepare": "theia build",
"start": "theia start",
"watch": "theia build --watch"
},
"theia": {
"target": "electron"
}
}
11 changes: 11 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lerna": "2.4.0",
"version": "0.0.0",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
"run": {
"stream": true
}
}
}
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"scripts": {
"prepare": "yarn tslint && lerna run prepare",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron",
"tslint-fix": "tslint --fix --project vi-extension",
"tslint": "tslint --project vi-extension"
},
"devDependencies": {
"lerna": "2.4.0",
"tslint": "5.10.0"
},
"workspaces": [
"vi-extension",
"browser-app",
"electron-app"
]
}
82 changes: 82 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"defaultSeverity": "error",
"rules": {
"file-header": [
true,
"SPDX-License-Identifier: EPL-2\\.0"
],
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"jsdoc-format": [
true,
"check-multiline-start"
],
"max-line-length": [
true,
180
],
"no-consecutive-blank-lines": true,
"no-shadowed-variable": true,
"no-string-throw": true,
"no-trailing-whitespace": true,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": {
"options": [
true,
{
"destructuring": "all"
}
]
},
"radix": true,
"semicolon": [
true,
"always",
"ignore-interfaces"
],
"trailing-comma": [
false
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}

30 changes: 30 additions & 0 deletions vi-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "vi-extension",
"keywords": [
"theia-extension"
],
"version": "0.0.0",
"files": [
"lib",
"src"
],
"dependencies": {
"@theia/core": "0.3.12",
"@theia/monaco": "0.3.12"
},
"devDependencies": {
"rimraf": "2.6.2",
"typescript": "2.7.2"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
},
"theiaExtensions": [
{
"frontend": "lib/browser/vi-frontend-module"
}
]
}
Loading