Skip to content

Commit

Permalink
Snippet sample
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Nov 14, 2018
1 parent 30b41ec commit a67f375
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .scripts/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ const lspSamples = [
{
description: 'Language Configuration Sample',
path: 'language-configuration-sample',
guide: 'https://vscode-ext-docs.azurewebsites.net/api/language-extensions/language-configuration-guide',
guide: '/api/language-extensions/language-configuration-guide',
apis: [],
contributions: ['languages']
},
{
description: 'Snippet Sample',
path: 'snippet-sample',
guide: '/api/language-extensions/snippet-guide',
apis: [],
contributions: ['snippets']
},
]

module.exports = {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ You can expect from each sample:
| [LSP Sample](lsp-sample) | [/api/language-extensions/smart-editing-lsp-guide](https://vscode-ext-docs.azurewebsites.net/api/language-extensions/smart-editing-lsp-guide) | |
| [LSP Log Streaming Sample](lsp-log-streaming-sample) | N/A | |
| [LSP Multi Root Server Sample](lsp-multi-server-sample) | https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs#language-client--language-server | |
| [Language Configuration Sample](language-configuration-sample) | https://vscode-ext-docs.azurewebsites.net/api/language-extensions/language-configuration-guide | [contributes.languages](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#contributes.languages) |
| [Language Configuration Sample](language-configuration-sample) | [/api/language-extensions/language-configuration-guide](https://vscode-ext-docs.azurewebsites.net/api/language-extensions/language-configuration-guide) | [contributes.languages](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#contributes.languages) |
| [Snippet Sample](snippet-sample) | [/api/language-extensions/snippet-guide](https://vscode-ext-docs.azurewebsites.net/api/language-extensions/snippet-guide) | [contributes.snippets](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#contributes.snippets) |
<!-- LSP_SAMPLES_END -->

## :warning: Legacy Samples :warning:
Expand Down
2 changes: 1 addition & 1 deletion language-configuration-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is the source code for the [Language Configuration Guide](https://vscode-ex

### Contribution Points

- [`contributes.languages`](https://code.visualstudio.com/docs/extensionAPI/extension-points#_contributeslanguages)
- [`contributes.languages`](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#contributes.languages)

## Running the Sample

Expand Down
2 changes: 1 addition & 1 deletion language-configuration-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"vscode": "^1.28.0"
},
"categories": [
"Other"
"Programming Languages"
],
"contributes": {
"languages": [
Expand Down
17 changes: 17 additions & 0 deletions snippet-sample/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
3 changes: 3 additions & 0 deletions snippet-sample/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.insertSpaces": false
}
14 changes: 14 additions & 0 deletions snippet-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Snippet Sample

This is the source code for [Snippet Guide](https://vscode-ext-docs.azurewebsites.net/api/language-extensions/snippet-guide).

## VS Code API

### Contribution Points

- [`contributes.snippets`](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#contributes.snippets)

## Running the Sample

- Run the `Run Extension` target in the Debug View
- When you type `log` in a JavaScript file, you would see the snippet `Print to console`.
21 changes: 21 additions & 0 deletions snippet-sample/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "snippet-sample",
"displayName": "Snippet Sample",
"description": "Snippet Sample",
"version": "0.0.1",
"publisher": "vscode-samples",
"engines": {
"vscode": "^1.28.0"
},
"categories": [
"Snippets"
],
"contributes": {
"snippets": [
{
"language": "javascript",
"path": "./snippets.json"
}
]
}
}
10 changes: 10 additions & 0 deletions snippet-sample/snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
}

0 comments on commit a67f375

Please sign in to comment.