From dbc468b5e4bfff198bf640509bc1200c6b2407c6 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 30 Dec 2016 18:51:37 +0100 Subject: [PATCH] start completions sample --- .gitignore | 4 +- .vscode/launch.json | 74 ++++++++++++++++++++++------- .vscode/tasks.json | 33 +++++-------- completions-sample/README.md | 1 + completions-sample/package.json | 28 +++++++++++ completions-sample/src/extension.ts | 19 ++++++++ completions-sample/tsconfig.json | 15 ++++++ package.json | 1 + 8 files changed, 135 insertions(+), 40 deletions(-) create mode 100644 completions-sample/README.md create mode 100644 completions-sample/package.json create mode 100644 completions-sample/src/extension.ts create mode 100644 completions-sample/tsconfig.json diff --git a/.gitignore b/.gitignore index 61dde3d0..0d1e97d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store npm-debug.log Thumbs.db -vim-sample/node_modules -vim-sample/out \ No newline at end of file +*/node_modules/ +*/out/ diff --git a/.vscode/launch.json b/.vscode/launch.json index b34a994b..346d11fd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,15 +2,34 @@ { "version": "0.1.0", "configurations": [ + { + "name": "Launch Completions Sample", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/completions-sample" + ], + "stopOnEntry": false, + "sourceMaps": true, + "outFiles": [ + "${workspaceRoot}/completions-sample/out/**/*.js" + ], + "preLaunchTask": "compile-completions" + }, { "name": "Launch Decorator Sample", "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}/decorator-sample" ], + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/decorator-sample" + ], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/decorator-sample/out/**/*.js"], + "outFiles": [ + "${workspaceRoot}/decorator-sample/out/**/*.js" + ], "preLaunchTask": "compile-decorator" }, { @@ -18,10 +37,14 @@ "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}/previewhtml-sample" ], + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/previewhtml-sample" + ], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/previewhtml-sample/out/**/*.js"], + "outFiles": [ + "${workspaceRoot}/previewhtml-sample/out/**/*.js" + ], "preLaunchTask": "compile-previewhtml" }, { @@ -29,10 +52,14 @@ "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}/contentprovider-sample" ], + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/contentprovider-sample" + ], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/contentprovider-sample/out/**/*.js"], + "outFiles": [ + "${workspaceRoot}/contentprovider-sample/out/**/*.js" + ], "preLaunchTask": "compile-contentprovider" }, { @@ -40,10 +67,14 @@ "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}/statusbar-sample" ], + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/statusbar-sample" + ], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/statusbar-sample/out/**/*.js"], + "outFiles": [ + "${workspaceRoot}/statusbar-sample/out/**/*.js" + ], "preLaunchTask": "compile-statusbar" }, { @@ -51,10 +82,14 @@ "type": "extensionHost", "request": "launch", "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}/languageprovider-sample" ], + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/languageprovider-sample" + ], "stopOnEntry": false, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/languageprovider-sample/client/out/**/*.js"] + "outFiles": [ + "${workspaceRoot}/languageprovider-sample/client/out/**/*.js" + ] }, { "name": "Attach Language Provider Sample Server", @@ -62,13 +97,18 @@ "request": "attach", "port": 6004, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/languageprovider-sample/server/out/**/*.js"] + "outFiles": [ + "${workspaceRoot}/languageprovider-sample/server/out/**/*.js" + ] } ], "compounds": [ - { - "name": "Launch Language Provider Sample & Attach to Server", - "configurations": ["Launch Language Provider Sample", "Attach Language Provider Sample Server"] - } - ] -} \ No newline at end of file + { + "name": "Launch Language Provider Sample & Attach to Server", + "configurations": [ + "Launch Language Provider Sample", + "Attach Language Provider Sample Server" + ] + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d2b175ac..0767d152 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,85 +5,76 @@ // ${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 run' "command": "npm", "args": [ "run" ], - // the command is a shell script "isShellCommand": true, - "tasks": [ { // in package.json we have a compile task for each example - "taskName": "compile-decorator", - + "taskName": "compile-completions", + // show the output window only if unrecognized errors occur. + "showOutput": "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" + }, + { + // in package.json we have a compile task for each example + "taskName": "compile-decorator", // show the output window only if unrecognized errors occur. "showOutput": "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" }, { // in package.json we have a compile task for each example "taskName": "compile-previewhtml", - // show the output window only if unrecognized errors occur. "showOutput": "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" }, { // in package.json we have a compile task for each example "taskName": "compile-statusbar", - // show the output window only if unrecognized errors occur. "showOutput": "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" }, { // in package.json we have a compile task for each example "taskName": "compile-contentprovider", - // show the output window only if unrecognized errors occur. "showOutput": "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" }, { // in package.json we have a compile task for each example "taskName": "compile-languageprovider", - // show the output window only if unrecognized errors occur. "showOutput": "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" } ] -} \ No newline at end of file +} diff --git a/completions-sample/README.md b/completions-sample/README.md new file mode 100644 index 00000000..7e2b11fd --- /dev/null +++ b/completions-sample/README.md @@ -0,0 +1 @@ +# Completion Item Provider Sample diff --git a/completions-sample/package.json b/completions-sample/package.json new file mode 100644 index 00000000..39eca773 --- /dev/null +++ b/completions-sample/package.json @@ -0,0 +1,28 @@ +{ + "name": "completions-sample", + "displayName": "Completion Item Provider Sample", + "version": "0.0.1", + "publisher": "jrieken", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/vscode-extension-samples" + }, + "bugs": { + "url": "https://github.com/Microsoft/vscode-extension-samples/issues" + }, + "engines": { + "vscode": "^1.5.0" + }, + "categories": [ + "Other" + ], + "activationEvents": [ + "*" + ], + "main": "./out/extension", + "devDependencies": { + "typescript": "^2.1.4", + "vscode": "^1.0.0", + "@types/node": "^6.0.40" + } +} diff --git a/completions-sample/src/extension.ts b/completions-sample/src/extension.ts new file mode 100644 index 00000000..158b85fd --- /dev/null +++ b/completions-sample/src/extension.ts @@ -0,0 +1,19 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +'use strict'; + +import * as vscode from 'vscode'; + +export function activate(context: vscode.ExtensionContext) { + + // The most simple completion item provider which + // * registers for text files (`'plaintext'`), and + // * only return the 'Hello World' completion + vscode.languages.registerCompletionItemProvider('plaintext', { + provideCompletionItems() { + return [new vscode.CompletionItem('Hello World')]; + } + }); +} diff --git a/completions-sample/tsconfig.json b/completions-sample/tsconfig.json new file mode 100644 index 00000000..c79b0fa0 --- /dev/null +++ b/completions-sample/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "outDir": "out", + "lib": [ + "es6" + ], + "sourceMap": true, + "rootDir": "src" + }, + "exclude": [ + "node_modules" + ] +} diff --git a/package.json b/package.json index abc4a33e..2e5d5ea9 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "version": "0.0.1", "scripts": { "postinstall": "node .build/postinstall.js", + "compile-completions": "cd completions-sample && tsc", "compile-decorator": "cd decorator-sample && npm run compile", "compile-previewhtml": "cd previewhtml-sample && npm run compile", "compile-contentprovider": "cd contentprovider-sample && npm run compile",