@@ -14,10 +14,16 @@ import {
14
14
} from "vscode-languageclient/node" ;
15
15
16
16
import registerUninstallCommand from "./commands/uninstall" ;
17
+ import registerToPipeCommand from "./commands/to-pipe" ;
18
+ import registerFromPipeCommand from "./commands/from-pipe" ;
17
19
18
20
let credoClient : LanguageClient ;
19
21
let nextLSClient : LanguageClient ;
20
22
23
+ const channel = vscode . window . createOutputChannel ( "elixir-tools.vscode" , {
24
+ log : true ,
25
+ } ) ;
26
+
21
27
async function latestRelease ( project : string ) : Promise < string > {
22
28
return fetch (
23
29
`https://api.github.com/repos/elixir-tools/${ project } /releases/latest` ,
@@ -101,8 +107,6 @@ async function activateNextLS(
101
107
) {
102
108
let config = vscode . workspace . getConfiguration ( "elixir-tools.nextLS" ) ;
103
109
104
- registerUninstallCommand ( config , context ) ;
105
-
106
110
if ( config . get ( "enable" ) ) {
107
111
let serverOptions : ServerOptions ;
108
112
@@ -163,11 +167,15 @@ async function activateNextLS(
163
167
164
168
nextLSClient = new LanguageClient (
165
169
"elixir-tools.nextLS" ,
166
- "NextLS " ,
170
+ "Next LS " ,
167
171
serverOptions ,
168
172
clientOptions
169
173
) ;
170
174
175
+ registerToPipeCommand ( nextLSClient , context ) ;
176
+ registerFromPipeCommand ( nextLSClient , context ) ;
177
+ registerUninstallCommand ( config , context ) ;
178
+
171
179
// Start the nextLSClient. This will also launch the server
172
180
nextLSClient . start ( ) ;
173
181
}
@@ -206,21 +214,14 @@ export async function ensureNextLSDownloaded(
206
214
const shouldDownload = opts . force || ( await isBinaryMissing ( bin ) ) ;
207
215
208
216
if ( shouldDownload ) {
217
+ channel . info ( "Next LS needs to be downloaded" ) ;
209
218
await fsp . mkdir ( cacheDir , { recursive : true } ) ;
210
219
211
220
const platform = getPlatform ( ) ;
212
221
const exe = getExe ( platform ) ;
213
222
const url = `https://github.com/elixir-tools/next-ls/releases/latest/download/${ exe } ` ;
214
223
215
- const shouldInstall = await vscode . window . showInformationMessage (
216
- "Install Next LS?" ,
217
- { modal : true , detail : `Downloading to '${ cacheDir } '` } ,
218
- { title : "Yes" }
219
- ) ;
220
-
221
- if ( shouldInstall ?. title !== "Yes" ) {
222
- throw new Error ( "Could not activate Next LS" ) ;
223
- }
224
+ channel . info ( `Starting download from ${ url } ` ) ;
224
225
225
226
await fetch ( url ) . then ( ( res ) => {
226
227
if ( res . ok ) {
@@ -230,10 +231,12 @@ export async function ensureNextLSDownloaded(
230
231
file . on ( "close" , resolve ) ;
231
232
file . on ( "error" , reject ) ;
232
233
} )
233
- . then ( ( ) => console . log ( "Downloaded NextLS!!" ) )
234
- . catch ( ( ) => console . log ( "Failed to download NextLS!!" ) ) ;
234
+ . then ( ( ) => channel . info ( "Downloaded NextLS!" ) )
235
+ . catch ( ( ) =>
236
+ channel . error ( "Failed to write downloaded executable to a file" )
237
+ ) ;
235
238
} else {
236
- throw new Error ( `Download failed ( ${ url } , status=${ res . status } ) `) ;
239
+ channel . error ( `Failed to write download Next LS: status=${ res . status } `) ;
237
240
}
238
241
} ) ;
239
242
await fsp . chmod ( bin , "755" ) ;
@@ -245,8 +248,10 @@ export async function ensureNextLSDownloaded(
245
248
async function isBinaryMissing ( bin : string ) {
246
249
try {
247
250
await fsp . access ( bin , fs . constants . X_OK ) ;
251
+ channel . info ( `Found Next LS executable at ${ bin } ` ) ;
248
252
return false ;
249
253
} catch {
254
+ channel . warn ( `Did not find Next LS executable at ${ bin } ` ) ;
250
255
return true ;
251
256
}
252
257
}
@@ -266,7 +271,7 @@ function getExe(platform: string) {
266
271
return "next_ls_darwin_amd64" ;
267
272
268
273
case "arm64" :
269
- return "next_ls_darwin_amd64 " ;
274
+ return "next_ls_darwin_arm64 " ;
270
275
}
271
276
272
277
case "linux" :
0 commit comments