@@ -9,22 +9,28 @@ const path = require('path')
9
9
const fs = require ( 'fs' )
10
10
11
11
const getLocation = ( context ) => {
12
- let config = vscode . workspace . getConfiguration ( 'reason_language_server' )
13
-
14
- let binaryLocation = config . get ( 'location' )
12
+ let binaryLocation = vscode . workspace . getConfiguration ( 'reason_language_server' ) . get ( 'location' )
15
13
16
14
if ( ! binaryLocation ) {
17
15
// see if it's bundled with the extension
18
16
// hmm actually I could bundle one for each platform & probably be fine
19
17
// I guess it's 9mb binary. I wonder if I can cut that down?
20
- binaryLocation = context . asAbsolutePath ( '../ bin.native')
18
+ binaryLocation = path . join ( vscode . workspace . rootPath , 'node_modules' , '@jaredly' , 'reason-language-server' , 'lib' , 'bs' , 'native' , ' bin.native')
21
19
if ( ! fs . existsSync ( binaryLocation ) ) {
22
- binaryLocation = path . join ( vscode . workspace . rootPath , 'node_modules' , '@jaredly' , 'reason-language-server' , 'lib' , 'bs' , 'native' , 'bin.native' )
20
+ binaryLocation = context . asAbsolutePath ( '../bin.native' )
21
+ if ( ! fs . existsSync ( binaryLocation ) ) {
22
+ vscode . window . showErrorMessage ( 'Reason Language Server not found! Please install the npm package @jaredly/reason-language-server to enable IDE functionality' ) ;
23
+ return null
24
+ }
23
25
}
24
26
} else {
25
27
if ( ! binaryLocation . startsWith ( '/' ) ) {
26
28
binaryLocation = path . join ( vscode . workspace . rootPath , binaryLocation )
27
29
}
30
+ if ( ! fs . existsSync ( binaryLocation ) ) {
31
+ vscode . window . showErrorMessage ( 'Reason Language Server not found! You specified ' + binaryLocation ) ;
32
+ return null
33
+ }
28
34
}
29
35
return binaryLocation
30
36
}
@@ -87,6 +93,7 @@ function activate(context) {
87
93
client . stop ( ) ;
88
94
}
89
95
const location = getLocation ( )
96
+ if ( ! location ) return
90
97
client = new LanguageClient (
91
98
'reason-language-server' ,
92
99
'Reason Language Server' ,
@@ -110,6 +117,12 @@ function activate(context) {
110
117
}
111
118
}
112
119
120
+ vscode . workspace . onDidChangeConfiguration ( evt => {
121
+ if ( evt . affectsConfiguration ( 'reason_language_server.location' ) ) {
122
+ restart ( )
123
+ }
124
+ } )
125
+
113
126
restart ( ) ;
114
127
115
128
vscode . commands . registerCommand ( 'reason-language-server.restart' , restart ) ;
0 commit comments