@@ -7,6 +7,7 @@ import { BunProc } from "../bun"
7
7
import { $ } from "bun"
8
8
import fs from "fs/promises"
9
9
import { Filesystem } from "../util/filesystem"
10
+ import { Flag } from "../flag/flag"
10
11
11
12
export namespace LSPServer {
12
13
const log = Log . create ( { service : "lsp.server" } )
@@ -95,6 +96,7 @@ export namespace LSPServer {
95
96
"vue-language-server.js" ,
96
97
)
97
98
if ( ! ( await Bun . file ( js ) . exists ( ) ) ) {
99
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
98
100
await Bun . spawn ( [ BunProc . which ( ) , "install" , "@vue/language-server" ] , {
99
101
cwd : Global . Path . bin ,
100
102
env : {
@@ -148,6 +150,7 @@ export namespace LSPServer {
148
150
if ( ! eslint ) return
149
151
const serverPath = path . join ( Global . Path . bin , "vscode-eslint" , "server" , "out" , "eslintServer.js" )
150
152
if ( ! ( await Bun . file ( serverPath ) . exists ( ) ) ) {
153
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
151
154
log . info ( "downloading and building VS Code ESLint server" )
152
155
const response = await fetch ( "https://github.com/microsoft/vscode-eslint/archive/refs/heads/main.zip" )
153
156
if ( ! response . ok ) return
@@ -200,6 +203,8 @@ export namespace LSPServer {
200
203
} )
201
204
if ( ! bin ) {
202
205
if ( ! Bun . which ( "go" ) ) return
206
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
207
+
203
208
log . info ( "installing gopls" )
204
209
const proc = Bun . spawn ( {
205
210
cmd : [ "go" , "install" , "golang.org/x/tools/gopls@latest" ] ,
@@ -241,6 +246,7 @@ export namespace LSPServer {
241
246
log . info ( "Ruby not found, please install Ruby first" )
242
247
return
243
248
}
249
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
244
250
log . info ( "installing ruby-lsp" )
245
251
const proc = Bun . spawn ( {
246
252
cmd : [ "gem" , "install" , "ruby-lsp" , "--bindir" , Global . Path . bin ] ,
@@ -276,6 +282,7 @@ export namespace LSPServer {
276
282
if ( ! binary ) {
277
283
const js = path . join ( Global . Path . bin , "node_modules" , "pyright" , "dist" , "pyright-langserver.js" )
278
284
if ( ! ( await Bun . file ( js ) . exists ( ) ) ) {
285
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
279
286
await Bun . spawn ( [ BunProc . which ( ) , "install" , "pyright" ] , {
280
287
cwd : Global . Path . bin ,
281
288
env : {
@@ -323,6 +330,7 @@ export namespace LSPServer {
323
330
return
324
331
}
325
332
333
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
326
334
log . info ( "downloading elixir-ls from GitHub releases" )
327
335
328
336
const response = await fetch ( "https://github.com/elixir-lsp/elixir-ls/archive/refs/heads/master.zip" )
@@ -372,6 +380,7 @@ export namespace LSPServer {
372
380
return
373
381
}
374
382
383
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
375
384
log . info ( "downloading zls from GitHub releases" )
376
385
377
386
const releaseResponse = await fetch ( "https://api.github.com/repos/zigtools/zls/releases/latest" )
@@ -475,6 +484,7 @@ export namespace LSPServer {
475
484
return
476
485
}
477
486
487
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
478
488
log . info ( "installing csharp-ls via dotnet tool" )
479
489
const proc = Bun . spawn ( {
480
490
cmd : [ "dotnet" , "tool" , "install" , "csharp-ls" , "--tool-path" , Global . Path . bin ] ,
@@ -527,6 +537,7 @@ export namespace LSPServer {
527
537
PATH : process . env [ "PATH" ] + ":" + Global . Path . bin ,
528
538
} )
529
539
if ( ! bin ) {
540
+ if ( Flag . OPENCODE_DISABLE_LSP_DOWNLOAD ) return
530
541
log . info ( "downloading clangd from GitHub releases" )
531
542
532
543
const releaseResponse = await fetch ( "https://api.github.com/repos/clangd/clangd/releases/latest" )
0 commit comments