77 */
88
99import * as path from 'path' ;
10- import { ExtensionContext , ProgressLocation , window , workspace } from 'vscode' ;
11- import { LanguageClient , LanguageClientOptions , RevealOutputChannelOn , ServerOptions , TransportKind } from 'vscode-languageclient' ;
10+ import * as vscode from 'vscode' ;
11+ import * as lsp from 'vscode-languageclient' ;
1212
13+ import { registerCommands } from './commands' ;
1314import { projectLoadingNotification } from './protocol' ;
1415
15- export function activate ( context : ExtensionContext ) {
16+ export function activate ( context : vscode . ExtensionContext ) {
1617 // Log file does not yet exist on disk. It is up to the server to create the
1718 // file.
1819 const logFile = path . join ( context . logPath , 'nglangsvc.log' ) ;
1920
2021 // If the extension is launched in debug mode then the debug server options are used
2122 // Otherwise the run options are used
22- const serverOptions : ServerOptions = {
23+ const serverOptions : lsp . ServerOptions = {
2324 run : {
2425 module : context . asAbsolutePath ( path . join ( 'server' , 'server.js' ) ) ,
25- transport : TransportKind . ipc ,
26+ transport : lsp . TransportKind . ipc ,
2627 args : [
2728 '--logFile' , logFile ,
2829 // TODO: Might want to turn off logging completely.
@@ -36,7 +37,7 @@ export function activate(context: ExtensionContext) {
3637 } ,
3738 debug : {
3839 module : context . asAbsolutePath ( path . join ( 'server' , 'out' , 'server.js' ) ) ,
39- transport : TransportKind . ipc ,
40+ transport : lsp . TransportKind . ipc ,
4041 args : [
4142 '--logFile' ,
4243 logFile ,
@@ -60,7 +61,7 @@ export function activate(context: ExtensionContext) {
6061 } ;
6162
6263 // Options to control the language client
63- const clientOptions : LanguageClientOptions = {
64+ const clientOptions : lsp . LanguageClientOptions = {
6465 // Register the server for Angular templates and TypeScript documents
6566 documentSelector : [
6667 // scheme: 'file' means listen to changes to files on disk only
@@ -72,31 +73,33 @@ export function activate(context: ExtensionContext) {
7273 synchronize : {
7374 fileEvents : [
7475 // Notify the server about file changes to tsconfig.json contained in the workspace
75- workspace . createFileSystemWatcher ( '**/tsconfig.json' ) ,
76+ vscode . workspace . createFileSystemWatcher ( '**/tsconfig.json' ) ,
7677 ]
7778 } ,
7879
7980 // Don't let our output console pop open
80- revealOutputChannelOn : RevealOutputChannelOn . Never
81+ revealOutputChannelOn : lsp . RevealOutputChannelOn . Never
8182 } ;
8283
8384 // Create the language client and start the client.
8485 const forceDebug = ! ! process . env [ 'NG_DEBUG' ] ;
8586 const client =
86- new LanguageClient ( 'Angular Language Service' , serverOptions , clientOptions , forceDebug ) ;
87- const disposable = client . start ( ) ;
87+ new lsp . LanguageClient ( 'Angular Language Service' , serverOptions , clientOptions , forceDebug ) ;
8888
8989 // Push the disposable to the context's subscriptions so that the
9090 // client can be deactivated on extension deactivation
91- context . subscriptions . push ( disposable ) ;
91+ context . subscriptions . push (
92+ ...registerCommands ( client ) ,
93+ client . start ( ) ,
94+ ) ;
9295
9396 client . onReady ( ) . then ( ( ) => {
9497 const projectLoadingTasks = new Map < string , { resolve : ( ) => void } > ( ) ;
9598
9699 client . onNotification ( projectLoadingNotification . start , ( projectName : string ) => {
97- window . withProgress (
100+ vscode . window . withProgress (
98101 {
99- location : ProgressLocation . Window ,
102+ location : vscode . ProgressLocation . Window ,
100103 title : 'Initializing Angular language features' ,
101104 } ,
102105 ( ) => new Promise ( ( resolve ) => {
0 commit comments