7
7
*/
8
8
9
9
import * 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' ;
12
12
13
+ import { registerCommands } from './commands' ;
13
14
import { projectLoadingNotification } from './protocol' ;
14
15
15
- export function activate ( context : ExtensionContext ) {
16
+ export function activate ( context : vscode . ExtensionContext ) {
16
17
// Log file does not yet exist on disk. It is up to the server to create the
17
18
// file.
18
19
const logFile = path . join ( context . logPath , 'nglangsvc.log' ) ;
19
20
20
21
// If the extension is launched in debug mode then the debug server options are used
21
22
// Otherwise the run options are used
22
- const serverOptions : ServerOptions = {
23
+ const serverOptions : lsp . ServerOptions = {
23
24
run : {
24
25
module : context . asAbsolutePath ( path . join ( 'server' , 'server.js' ) ) ,
25
- transport : TransportKind . ipc ,
26
+ transport : lsp . TransportKind . ipc ,
26
27
args : [
27
28
'--logFile' , logFile ,
28
29
// TODO: Might want to turn off logging completely.
@@ -36,7 +37,7 @@ export function activate(context: ExtensionContext) {
36
37
} ,
37
38
debug : {
38
39
module : context . asAbsolutePath ( path . join ( 'server' , 'out' , 'server.js' ) ) ,
39
- transport : TransportKind . ipc ,
40
+ transport : lsp . TransportKind . ipc ,
40
41
args : [
41
42
'--logFile' ,
42
43
logFile ,
@@ -60,7 +61,7 @@ export function activate(context: ExtensionContext) {
60
61
} ;
61
62
62
63
// Options to control the language client
63
- const clientOptions : LanguageClientOptions = {
64
+ const clientOptions : lsp . LanguageClientOptions = {
64
65
// Register the server for Angular templates and TypeScript documents
65
66
documentSelector : [
66
67
// scheme: 'file' means listen to changes to files on disk only
@@ -72,31 +73,33 @@ export function activate(context: ExtensionContext) {
72
73
synchronize : {
73
74
fileEvents : [
74
75
// Notify the server about file changes to tsconfig.json contained in the workspace
75
- workspace . createFileSystemWatcher ( '**/tsconfig.json' ) ,
76
+ vscode . workspace . createFileSystemWatcher ( '**/tsconfig.json' ) ,
76
77
]
77
78
} ,
78
79
79
80
// Don't let our output console pop open
80
- revealOutputChannelOn : RevealOutputChannelOn . Never
81
+ revealOutputChannelOn : lsp . RevealOutputChannelOn . Never
81
82
} ;
82
83
83
84
// Create the language client and start the client.
84
85
const forceDebug = ! ! process . env [ 'NG_DEBUG' ] ;
85
86
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 ) ;
88
88
89
89
// Push the disposable to the context's subscriptions so that the
90
90
// client can be deactivated on extension deactivation
91
- context . subscriptions . push ( disposable ) ;
91
+ context . subscriptions . push (
92
+ ...registerCommands ( client ) ,
93
+ client . start ( ) ,
94
+ ) ;
92
95
93
96
client . onReady ( ) . then ( ( ) => {
94
97
const projectLoadingTasks = new Map < string , { resolve : ( ) => void } > ( ) ;
95
98
96
99
client . onNotification ( projectLoadingNotification . start , ( projectName : string ) => {
97
- window . withProgress (
100
+ vscode . window . withProgress (
98
101
{
99
- location : ProgressLocation . Window ,
102
+ location : vscode . ProgressLocation . Window ,
100
103
title : 'Initializing Angular language features' ,
101
104
} ,
102
105
( ) => new Promise ( ( resolve ) => {
0 commit comments