initial commit
This commit is contained in:
Коммит
4818008726
|
@ -0,0 +1,2 @@
|
||||||
|
out
|
||||||
|
node_modules
|
|
@ -0,0 +1,28 @@
|
||||||
|
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Extension",
|
||||||
|
"type": "extensionHost",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeExecutable": "${execPath}",
|
||||||
|
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||||
|
"stopOnEntry": false,
|
||||||
|
"sourceMaps": true,
|
||||||
|
"outDir": "${workspaceRoot}/out/src",
|
||||||
|
"preLaunchTask": "npm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Launch Tests",
|
||||||
|
"type": "extensionHost",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeExecutable": "${execPath}",
|
||||||
|
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
|
||||||
|
"stopOnEntry": false,
|
||||||
|
"sourceMaps": true,
|
||||||
|
"outDir": "${workspaceRoot}/out/test",
|
||||||
|
"preLaunchTask": "npm"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Available variables which can be used inside of strings.
|
||||||
|
// ${workspaceRoot}: the root folder of the team
|
||||||
|
// ${file}: the current opened file
|
||||||
|
// ${fileBasename}: the current opened file's basename
|
||||||
|
// ${fileDirname}: the current opened file's dirname
|
||||||
|
// ${fileExtname}: the current opened file's extension
|
||||||
|
// ${cwd}: the current working directory of the spawned process
|
||||||
|
|
||||||
|
// A task runner that calls a custom npm script that compiles the extension.
|
||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
|
||||||
|
// we want to run npm
|
||||||
|
"command": "npm",
|
||||||
|
|
||||||
|
// the command is a shell script
|
||||||
|
"isShellCommand": true,
|
||||||
|
|
||||||
|
// show the output window only if unrecognized errors occur.
|
||||||
|
"showOutput": "silent",
|
||||||
|
|
||||||
|
// we run the custom script "compile" as defined in package.json
|
||||||
|
"args": ["run", "compile", "--loglevel", "silent"],
|
||||||
|
|
||||||
|
// The tsc compiler is started in watching mode
|
||||||
|
"isWatching": true,
|
||||||
|
|
||||||
|
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
|
||||||
|
"problemMatcher": "$tsc-watch"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
.vscode/**
|
||||||
|
typings/**
|
||||||
|
out/test/**
|
||||||
|
test/**
|
||||||
|
src/**
|
||||||
|
**/*.map
|
||||||
|
.gitignore
|
||||||
|
tsconfig.json
|
||||||
|
vsc-extension-quickstart.md
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"name": "formatter-sample",
|
||||||
|
"displayName": "formatter-sample",
|
||||||
|
"description": "",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"publisher": "jrieken",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.6.0"
|
||||||
|
},
|
||||||
|
"categories": [
|
||||||
|
"Other"
|
||||||
|
],
|
||||||
|
"activationEvents": [
|
||||||
|
"onLanguage:foo-lang"
|
||||||
|
],
|
||||||
|
"main": "./out/src/extension",
|
||||||
|
"contributes": {
|
||||||
|
"languages": [
|
||||||
|
{
|
||||||
|
"id": "foo-lang",
|
||||||
|
"aliases": [
|
||||||
|
"Foo"
|
||||||
|
],
|
||||||
|
"extensions": [
|
||||||
|
"foo"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"command": "extension.format-foo",
|
||||||
|
"title": "(Bad) Format Foo Files"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "node ./node_modules/vscode/bin/install"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"vscode": "1.0.3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
|
||||||
|
// 👎 formatter implemented as separate command
|
||||||
|
vscode.commands.registerCommand('extension.format-foo', () => {
|
||||||
|
const {activeTextEditor} = vscode.window;
|
||||||
|
|
||||||
|
if (activeTextEditor && activeTextEditor.document.languageId === 'foo-lang') {
|
||||||
|
const {document} = activeTextEditor;
|
||||||
|
const firstLine = document.lineAt(0);
|
||||||
|
if (firstLine.text !== '42') {
|
||||||
|
const edit = new vscode.WorkspaceEdit();
|
||||||
|
edit.insert(document.uri, firstLine.range.start, '42\n');
|
||||||
|
return vscode.workspace.applyEdit(edit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 👍 formatter implemented using API
|
||||||
|
vscode.languages.registerDocumentFormattingEditProvider('foo-lang', {
|
||||||
|
provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] {
|
||||||
|
const firstLine = document.lineAt(0);
|
||||||
|
if (firstLine.text !== '42') {
|
||||||
|
return [vscode.TextEdit.insert(firstLine.range.start, '42\n')];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"outDir": "out",
|
||||||
|
"lib": [
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"sourceMap": true,
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
".vscode-test"
|
||||||
|
]
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче