Skip to content

Commit 0b0116e

Browse files
committed
WIP: Angular 2 language service
0 parents  commit 0b0116e

File tree

11 files changed

+4238
-0
lines changed

11 files changed

+4238
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
client/node_modules/
2+
client/out/
3+
client/server/
4+
server/node_modules/
5+
.vscode/
6+
.DS_Store

client/language-configuration.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"comments": {
3+
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
4+
"blockComment": [ "<!--", "-->" ]
5+
},
6+
// symbols used as brackets
7+
"brackets": [
8+
["<", ">"],
9+
["{{", "}}"]
10+
],
11+
// symbols that are auto closed when typing
12+
"autoClosingPairs": [
13+
["<", ">"],
14+
["[", "]"],
15+
["(", ")"],
16+
["{", "}"],
17+
["\"", "\""],
18+
["'", "'"]
19+
],
20+
// symbols that that can be used to surround a selection
21+
"surroundingPairs": [
22+
["[", "]"],
23+
["(", ")"],
24+
["\"", "\""],
25+
["'", "'"]
26+
]
27+
}

client/package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "ng-template",
3+
"displayName": "Angular Template",
4+
"description": "Angular Template Service",
5+
"version": "0.0.1",
6+
"publisher": "Google",
7+
"engines": {
8+
"vscode": "^1.4.0"
9+
},
10+
"categories": [
11+
"Languages"
12+
],
13+
"activationEvents": [
14+
"onLanguage:ng-template"
15+
],
16+
"main": "./out/extension",
17+
"contributes": {
18+
"languages": [
19+
{
20+
"id": "ng-template",
21+
"aliases": [
22+
"Angular Template",
23+
"ng",
24+
"ng-html"
25+
],
26+
"extensions": [
27+
".ng",
28+
".ngml"
29+
],
30+
"configuration": "./language-configuration.json"
31+
}
32+
],
33+
"grammars": [
34+
{
35+
"language": "ng-template",
36+
"scopeName": "text.html.basic",
37+
"path": "./syntaxes/NG.plist"
38+
}
39+
]
40+
},
41+
"scripts": {
42+
"postinstall": "node ./node_modules/vscode/bin/install"
43+
},
44+
"devDependencies": {
45+
"@types/node": "^6.0.38",
46+
"typescript": "^2.1.0-dev.20160830",
47+
"vscode": "^0.11.15"
48+
},
49+
"dependencies": {
50+
"vscode-languageclient": "^2.4.2-next.12"
51+
}
52+
}

client/src/extension.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/// <reference path="../node_modules/vscode/typings/index.d.ts" />
2+
3+
import * as path from 'path';
4+
5+
import { workspace, Disposable, ExtensionContext } from 'vscode';
6+
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient';
7+
8+
export function activate(context: ExtensionContext) {
9+
// The server is implemented in node
10+
let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
11+
// The debug options for the server
12+
let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };
13+
14+
// If the extension is launched in debug mode then the debug server options are used
15+
// Otherwise the run options are used
16+
let serverOptions: ServerOptions = {
17+
run : { module: serverModule, transport: TransportKind.ipc },
18+
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
19+
}
20+
21+
// Options to control the language client
22+
let clientOptions: LanguageClientOptions = {
23+
// Register the server for plain text documents
24+
documentSelector: ['ng-template'],
25+
synchronize: {
26+
fileEvents: [
27+
workspace.createFileSystemWatcher('**/tsconfig.json'),
28+
workspace.createFileSystemWatcher('**/*.ts')
29+
],
30+
textDocumentFilter: document => document.fileName.endsWith('.ts')
31+
},
32+
}
33+
34+
// Create the language client and start the client.
35+
let disposable = new LanguageClient('Angular Language Service', serverOptions, clientOptions, true).start();
36+
37+
// Push the disposable to the context's subscriptions so that the
38+
// client can be deactivated on extension deactivation
39+
context.subscriptions.push(disposable);
40+
}
41+

0 commit comments

Comments
 (0)