feat(lsp): add OPENCODE_DISABLE_LSP env var to skip all LSP servers#16271
feat(lsp): add OPENCODE_DISABLE_LSP env var to skip all LSP servers#16271marcusquinn wants to merge 1 commit intoanomalyco:devfrom
Conversation
Headless `opencode run` sessions don't benefit from LSP diagnostics, but each session spawns its own LSP servers. On shell-heavy projects, bash-language-server's hardcoded --external-sources flag causes exponential ShellCheck memory growth (3-5 GB per process). This adds OPENCODE_DISABLE_LSP=true to skip all LSP initialization, complementing the existing OPENCODE_DISABLE_LSP_DOWNLOAD flag and the per-server config.lsp disable option. Closes anomalyco#16269
|
Note: the root cause of the
This PR ( |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Upstream root cause fix mergedbash-lsp/bash-language-server#1376 has been merged. bash-language-server now supports This PR is still useful — headless |
Issue for this PR
Closes #16269
Type of change
What does this PR do?
Adds
OPENCODE_DISABLE_LSP=trueenvironment variable to completely skip LSP server initialization.Headless
opencode runsessions don't benefit from LSP diagnostics — the LLM doesn't use them. But each session spawns its own set of LSP servers. On shell-heavy projects, bash-language-server's hardcoded--external-sourcesflag causes exponential ShellCheck memory growth (3-5 GB RSS per process, never terminates). With multiple concurrent sessions, this compounds rapidly — we observed 73 concurrent shellcheck processes consuming 17.8 GB RAM on a 64 GB machine.The flag is checked at the top of the LSP state initializer, before the existing
cfg.lsp === falseconfig check. When set, it returns an empty state with no servers — no LSP processes are spawned, no downloads attempted, no memory consumed.This complements the existing controls:
OPENCODE_DISABLE_LSP_DOWNLOAD— prevents downloading LSP binaries but still runs already-installed onesconfig.lsp: false/ per-serverdisabled: true— config-file based controlOPENCODE_DISABLE_LSP(new) — env var to skip everything, ideal for headless/CI useOPENCODE_DISABLE_LSP=true opencode run "implement feature X"Related: #5363, #13041, #13796, #4957, #12976, #8947
How did you verify your code works?
OPENCODE_DISABLE_LSP=true bun dev— confirmed zero LSP processes spawnedbun devwithout the flag — LSP servers start normallybun turbo typecheck— zero errorsScreenshots / recordings
N/A — no UI changes.
Checklist