1
1
const vscode = require ( "vscode" ) ;
2
- const lc = require ( "vscode-languageclient/node" ) ;
2
+ const { LanguageClient } = require ( "vscode-languageclient/node" ) ;
3
3
4
- module . exports = { activate, deactivate } ;
5
-
6
- async function deactivate ( ) { }
4
+ module . exports = { activate } ;
7
5
8
6
/**
9
7
* @param {vscode.ExtensionContext } context
10
- * @returns Promise<HdxExtensionContext >
8
+ * @returns Promise<void >
11
9
*/
12
10
async function activate ( context ) {
13
- console . error ( "Extension active" ) ;
14
- const hdxContext = new HdxExtensionContext ( context ) ;
15
- await hdxContext . activate ( ) ;
16
- return hdxContext ;
17
- }
18
-
19
- class HdxExtensionContext {
20
- /**
21
- * @public
22
- * @readonly
23
- * @type lc.LanguageClient
24
- */
25
- client ;
26
-
27
- /**
28
- * @public
29
- * @readonly
30
- * @type vscode.ExtensionContext
31
- */
32
- context ;
33
-
34
- constructor ( context ) {
35
- this . context = context ;
36
- }
37
-
38
- async activate ( ) {
39
- this . client = await this . createClient ( ) ;
40
- this . client . start ( ) ;
41
- }
42
-
43
- async deactivate ( ) {
44
- return this . client ?. stop ( ) ;
45
- }
46
-
47
- /**
48
- * @returns Promise<lc.LanguageClient>
49
- */
50
- async createClient ( ) {
51
- const traceOutputChannel = vscode . window . createOutputChannel ( "hdx Language Server Trace" ) ;
52
- const env = Object . assign ( { } , process . env ) ;
53
- const serverOptions = {
11
+ const traceOutputChannel = vscode . window . createOutputChannel ( "hdx Language Server Trace" ) ;
12
+ const env = Object . assign ( { } , process . env ) ;
13
+ const client = new LanguageClient (
14
+ "hdx" ,
15
+ "hdx Language Server" ,
16
+ {
54
17
run : {
55
18
command : env . HDX_SERVER_PATH || "hdx" ,
56
19
args : [ "lsp" ] ,
@@ -61,14 +24,12 @@ class HdxExtensionContext {
61
24
args : [ "--debug" , "lsp" ] ,
62
25
options : { env } ,
63
26
} ,
64
- } ;
65
- const clientOptions = {
27
+ } ,
28
+ {
66
29
documentSelector : [ { scheme : "file" , language : "css" } ] ,
67
30
diagnosticCollectionName : "hdx" ,
68
31
traceOutputChannel,
69
- } ;
70
-
71
- console . log ( { serverOptions, clientOptions } ) ;
72
- return new lc . LanguageClient ( "hdx" , "hdx Language Server" , serverOptions , clientOptions ) ;
73
- }
32
+ } ,
33
+ ) ;
34
+ context . subscriptions . push ( client . start ( ) ) ;
74
35
}
0 commit comments