@@ -5,12 +5,20 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Re
55
66export function activate ( context : ExtensionContext ) {
77
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+
812 // If the extension is launched in debug mode then the debug server options are used
913 // Otherwise the run options are used
1014 const serverOptions : ServerOptions = {
1115 run : {
1216 module : context . asAbsolutePath ( path . join ( 'server' , 'server.js' ) ) ,
1317 transport : TransportKind . ipc ,
18+ args : [
19+ '--logFile' , logFile ,
20+ // TODO: Might want to turn off logging completely.
21+ ] ,
1422 options : {
1523 env : {
1624 // Force TypeScript to use the non-polling version of the file watchers.
@@ -21,29 +29,40 @@ export function activate(context: ExtensionContext) {
2129 debug : {
2230 module : context . asAbsolutePath ( path . join ( 'server' , 'out' , 'server.js' ) ) ,
2331 transport : TransportKind . ipc ,
32+ args : [
33+ '--logFile' , logFile ,
34+ '--logVerbosity' , 'verbose' ,
35+ ] ,
2436 options : {
2537 env : {
2638 // Force TypeScript to use the non-polling version of the file watchers.
2739 TSC_NONPOLLING_WATCHER : true ,
2840 NG_DEBUG : true ,
2941 } ,
3042 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' ,
3247 ]
3348 } ,
3449 } ,
3550 }
3651
3752 // Options to control the language client
3853 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+ ] ,
4161
42- // Information in the TypeScript project is necessary to generate Angular template completions
4362 synchronize : {
4463 fileEvents : [
64+ // Notify the server about file changes to tsconfig.json contained in the workspace
4565 workspace . createFileSystemWatcher ( '**/tsconfig.json' ) ,
46- workspace . createFileSystemWatcher ( '**/*.ts' )
4766 ]
4867 } ,
4968
@@ -52,7 +71,8 @@ export function activate(context: ExtensionContext) {
5271 }
5372
5473 // 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 ( ) ;
5676
5777 // Push the disposable to the context's subscriptions so that the
5878 // client can be deactivated on extension deactivation
0 commit comments