Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 71d26c9

Browse files
committed
initial commit
0 parents  commit 71d26c9

12 files changed

+180
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.vscode/launch.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
{
3+
"version": "0.1.0",
4+
"configurations": [
5+
{
6+
"name": "Launch Extension",
7+
"type": "extensionHost",
8+
"request": "launch",
9+
"runtimeExecutable": "${execPath}",
10+
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
11+
"stopOnEntry": false
12+
},
13+
{
14+
"name": "Launch Tests",
15+
"type": "extensionHost",
16+
"request": "launch",
17+
"runtimeExecutable": "${execPath}",
18+
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ],
19+
"stopOnEntry": false
20+
}
21+
]
22+
}

.vscodeignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.vscode/**
2+
typings/**
3+
test/**
4+
.gitignore
5+
jsconfig.json
6+
vsc-extension-quickstart.md

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# README
2+
## Paste and format
3+
Paste and format with ctrl/cmd + shift + v

extension.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// The module 'vscode' contains the VS Code extensibility API
2+
// Import the module and reference it with the alias vscode in your code below
3+
var vscode = require('vscode');
4+
5+
// this method is called when your extension is activated
6+
// your extension is activated the very first time the command is executed
7+
function activate(context) {
8+
9+
// Use the console to output diagnostic information (console.log) and errors (console.error)
10+
// This line of code will only be executed once when your extension is activated
11+
console.log('Congratulations, your extension "pasteandformat" is now active!');
12+
13+
// The command has been defined in the package.json file
14+
// Now provide the implementation of the command with registerCommand
15+
// The commandId parameter must match the command field in package.json
16+
var disposable = vscode.commands.registerCommand('extension.pasteAndFormat', function () {
17+
vscode.commands.executeCommand('editor.action.clipboardPasteAction'); //Paste from clipboard
18+
vscode.commands.executeCommand('editor.action.format'); // Format document
19+
});
20+
21+
context.subscriptions.push(disposable);
22+
}
23+
exports.activate = activate;
24+
25+
// this method is called when your extension is deactivated
26+
function deactivate() {
27+
}
28+
exports.deactivate = deactivate;

jsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "ES5",
5+
"noLib": true
6+
},
7+
"exclude": [
8+
"node_modules"
9+
]
10+
}

package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "pasteandformat",
3+
"displayName": "pasteandformat",
4+
"description": "Paste and format with one command",
5+
"version": "0.0.1",
6+
"publisher": "spoeken",
7+
"engines": {
8+
"vscode": "^0.10.1"
9+
},
10+
"categories": [
11+
"Other"
12+
],
13+
"activationEvents": [
14+
"onCommand:extension.pasteAndFormat"
15+
],
16+
"main": "./extension",
17+
"contributes": {
18+
"keybindings": [{
19+
"command": "extension.pasteAndFormat",
20+
"key": "ctrl+shift+v",
21+
"mac": "cmd+shift+v",
22+
"when": "editorTextFocus"
23+
}]
24+
},
25+
26+
"devDependencies": {
27+
"vscode": "0.10.x"
28+
}
29+
}

test/extension.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* global suite, test */
2+
3+
//
4+
// Note: This example test is leveraging the Mocha test framework.
5+
// Please refer to their documentation on https://mochajs.org/ for help.
6+
//
7+
8+
// The module 'assert' provides assertion methods from node
9+
var assert = require('assert');
10+
11+
// You can import and use all API from the 'vscode' module
12+
// as well as import your extension to test it
13+
var vscode = require('vscode');
14+
var myExtension = require('../extension');
15+
16+
// Defines a Mocha test suite to group tests of similar kind together
17+
suite("Extension Tests", function() {
18+
19+
// Defines a Mocha unit test
20+
test("Something 1", function() {
21+
assert.equal(-1, [1, 2, 3].indexOf(5));
22+
assert.equal(-1, [1, 2, 3].indexOf(0));
23+
});
24+
});

test/index.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3+
//
4+
// This file is providing the test runner to use when running extension tests.
5+
// By default the test runner in use is Mocha based.
6+
//
7+
// You can provide your own test runner if you want to override it by exporting
8+
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
9+
// host can call to run the tests. The test runner is expected to use console.log
10+
// to report the results back to the caller. When the tests are finished, return
11+
// a possible error to the callback or null if none.
12+
13+
var testRunner = require('vscode/lib/testrunner');
14+
15+
// You can directly control Mocha options by uncommenting the following lines
16+
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17+
testRunner.configure({
18+
ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.)
19+
useColors: true // colored output from test results
20+
});
21+
22+
module.exports = testRunner;

typings/node.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../node_modules/vscode/typings/node.d.ts" />

typings/vscode-typings.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../node_modules/vscode/typings/index-js.d.ts" />

vsc-extension-quickstart.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Welcome to your first VS Code Extension
2+
3+
## What's in the folder
4+
* This folder contains all of the files necessary for your extension
5+
* `package.json` - this is the manifest file in which you declare your extension and command.
6+
The sample plugin registers a command and defines its title and command name. With this information
7+
VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
8+
* `extension.js` - this is the main file where you will provide the implementation of your command.
9+
The file exports one function, `activate`, which is called the very first time your extension is
10+
activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
11+
We pass the function containing the implementation of the command as the second parameter to
12+
`registerCommand`.
13+
14+
## Get up and running straight away
15+
* press `F5` to open a new window with your extension loaded
16+
* run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`
17+
* set breakpoints in your code inside extension.ts to debug your extension
18+
* find output from your extension in the debug console
19+
20+
## Make changes
21+
* you can relaunch the extension from the debug toolbar after changing code in `extension.js`
22+
* you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes
23+
24+
## Explore the API
25+
* you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`
26+
27+
## Run tests
28+
* open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
29+
* press `F5` to run the tests in a new window with your extension loaded
30+
* see the output of the test result in the debug console
31+
* make changes to `test/extension.test.js` or create new test files inside the `test` folder
32+
* by convention, the test runner will only consider files matching the name pattern `**.test.js`
33+
* you can create folders inside the `test` folder to structure your tests any way you want

0 commit comments

Comments
 (0)