diff --git a/completions-sample/package.json b/completions-sample/package.json index 39eca773..1944b41f 100644 --- a/completions-sample/package.json +++ b/completions-sample/package.json @@ -1,7 +1,7 @@ { "name": "completions-sample", "displayName": "Completion Item Provider Sample", - "version": "0.0.1", + "version": "0.0.2", "publisher": "jrieken", "repository": { "type": "git", @@ -11,7 +11,7 @@ "url": "https://github.com/Microsoft/vscode-extension-samples/issues" }, "engines": { - "vscode": "^1.5.0" + "vscode": "^1.18.0" }, "categories": [ "Other" @@ -20,9 +20,15 @@ "*" ], "main": "./out/extension", + "scripts": { + "vscode:prepublish": "tsc -p ./", + "compile": "tsc -watch -p ./", + "postinstall": "node ./node_modules/vscode/bin/install", + "tslint": "tslint -c tslint.json src/extension.ts" + }, "devDependencies": { "typescript": "^2.1.4", - "vscode": "^1.0.0", + "vscode": "^1.1.10", "@types/node": "^6.0.40" } } diff --git a/completions-sample/src/extension.ts b/completions-sample/src/extension.ts index 158b85fd..d0fb1016 100644 --- a/completions-sample/src/extension.ts +++ b/completions-sample/src/extension.ts @@ -10,10 +10,30 @@ 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 + // * return the 'Hello World' and + // a snippet-based completion item. vscode.languages.registerCompletionItemProvider('plaintext', { provideCompletionItems() { - return [new vscode.CompletionItem('Hello World')]; + return [ + new vscode.CompletionItem('Hello World!'), + createSnippetItem() + ]; } }); + + function createSnippetItem(): vscode.CompletionItem { + + // Read more here: + // https://code.visualstudio.com/docs/extensionAPI/vscode-api#CompletionItem + // https://code.visualstudio.com/docs/extensionAPI/vscode-api#SnippetString + + // For SnippetString syntax look here: + // https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets + + let item = new vscode.CompletionItem('Good part of the day', vscode.CompletionItemKind.Snippet); + item.insertText = new vscode.SnippetString("Good ${1|morning,afternoon,evening|}."); + item.documentation = new vscode.MarkdownString("Inserts a snippet that lets you select the _appropriate_ part of the day for your greeting."); + + return item; + } } diff --git a/lsp-sample/server/src/server.ts b/lsp-sample/server/src/server.ts index 5e017514..2737ddac 100644 --- a/lsp-sample/server/src/server.ts +++ b/lsp-sample/server/src/server.ts @@ -20,8 +20,8 @@ let documents: TextDocuments = new TextDocuments(); // for open, change and close text document events documents.listen(connection); -// After the server has started the client sends an initilize request. The server receives -// in the passed params the rootPath of the workspace plus the client capabilites. +// After the server has started the client sends an initialize request. The server receives +// in the passed params the rootPath of the workspace plus the client capabilities. let workspaceRoot: string; connection.onInitialize((params): InitializeResult => { workspaceRoot = params.rootPath; @@ -91,7 +91,7 @@ function validateTextDocument(textDocument: TextDocument): void { connection.onDidChangeWatchedFiles((_change) => { // Monitored files have change in VSCode - connection.console.log('We recevied an file change event'); + connection.console.log('We received an file change event'); }); diff --git a/previewhtml-sample/src/extension.ts b/previewhtml-sample/src/extension.ts index e02e8a56..bb9e8aed 100644 --- a/previewhtml-sample/src/extension.ts +++ b/previewhtml-sample/src/extension.ts @@ -61,7 +61,7 @@ export function activate(context: vscode.ExtensionContext) { }
-