@@ -5,12 +5,20 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Re
5
5
6
6
export function activate ( context : ExtensionContext ) {
7
7
8
+ // Log file does not yet exist on disk. It is up to the server to create the
9
+ // file.
10
+ const logFile = path . join ( context . logPath , 'nglangsvc.log' ) ;
11
+
8
12
// If the extension is launched in debug mode then the debug server options are used
9
13
// Otherwise the run options are used
10
14
const serverOptions : ServerOptions = {
11
15
run : {
12
16
module : context . asAbsolutePath ( path . join ( 'server' , 'server.js' ) ) ,
13
17
transport : TransportKind . ipc ,
18
+ args : [
19
+ '--logFile' , logFile ,
20
+ // TODO: Might want to turn off logging completely.
21
+ ] ,
14
22
options : {
15
23
env : {
16
24
// Force TypeScript to use the non-polling version of the file watchers.
@@ -21,29 +29,40 @@ export function activate(context: ExtensionContext) {
21
29
debug : {
22
30
module : context . asAbsolutePath ( path . join ( 'server' , 'out' , 'server.js' ) ) ,
23
31
transport : TransportKind . ipc ,
32
+ args : [
33
+ '--logFile' , logFile ,
34
+ '--logVerbosity' , 'verbose' ,
35
+ ] ,
24
36
options : {
25
37
env : {
26
38
// Force TypeScript to use the non-polling version of the file watchers.
27
39
TSC_NONPOLLING_WATCHER : true ,
28
40
NG_DEBUG : true ,
29
41
} ,
30
42
execArgv : [
31
- "--inspect=6009" , // If this is changed, update .vscode/launch.json as well
43
+ // do not lazily evaluate the code so all breakpoints are respected
44
+ '--nolazy' ,
45
+ // If debugging port is changed, update .vscode/launch.json as well
46
+ '--inspect=6009' ,
32
47
]
33
48
} ,
34
49
} ,
35
50
}
36
51
37
52
// Options to control the language client
38
53
const clientOptions : LanguageClientOptions = {
39
- // Register the server for Angular templates
40
- documentSelector : [ 'ng-template' , 'html' , 'typescript' ] ,
54
+ // Register the server for Angular templates and TypeScript documents
55
+ documentSelector : [
56
+ // scheme: 'file' means listen to changes to files on disk only
57
+ // other option is 'untitled', for buffer in the editor (like a new doc)
58
+ { scheme : 'file' , language : 'html' } ,
59
+ { scheme : 'file' , language : 'typescript' } ,
60
+ ] ,
41
61
42
- // Information in the TypeScript project is necessary to generate Angular template completions
43
62
synchronize : {
44
63
fileEvents : [
64
+ // Notify the server about file changes to tsconfig.json contained in the workspace
45
65
workspace . createFileSystemWatcher ( '**/tsconfig.json' ) ,
46
- workspace . createFileSystemWatcher ( '**/*.ts' )
47
66
]
48
67
} ,
49
68
@@ -52,7 +71,8 @@ export function activate(context: ExtensionContext) {
52
71
}
53
72
54
73
// Create the language client and start the client.
55
- const disposable = new LanguageClient ( 'Angular Language Service' , serverOptions , clientOptions ) . start ( ) ;
74
+ const client = new LanguageClient ( 'Angular Language Service' , serverOptions , clientOptions ) ;
75
+ const disposable = client . start ( ) ;
56
76
57
77
// Push the disposable to the context's subscriptions so that the
58
78
// client can be deactivated on extension deactivation
0 commit comments