Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 81ebf56

Browse files
committed
feat: add top level lsp: false and formatter: false to allow disabling all formatters or lsps at once
1 parent 429708e commit 81ebf56

4 files changed

Lines changed: 77 additions & 47 deletions

File tree

packages/opencode/src/config/config.ts

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -542,36 +542,43 @@ export namespace Config {
542542
.describe("Custom provider configurations and model overrides"),
543543
mcp: z.record(z.string(), Mcp).optional().describe("MCP (Model Context Protocol) server configurations"),
544544
formatter: z
545-
.record(
546-
z.string(),
547-
z.object({
548-
disabled: z.boolean().optional(),
549-
command: z.array(z.string()).optional(),
550-
environment: z.record(z.string(), z.string()).optional(),
551-
extensions: z.array(z.string()).optional(),
552-
}),
553-
)
554-
.optional(),
555-
lsp: z
556-
.record(
557-
z.string(),
558-
z.union([
545+
.union([
546+
z.literal(false),
547+
z.record(
548+
z.string(),
559549
z.object({
560-
disabled: z.literal(true),
561-
}),
562-
z.object({
563-
command: z.array(z.string()),
564-
extensions: z.array(z.string()).optional(),
565550
disabled: z.boolean().optional(),
566-
env: z.record(z.string(), z.string()).optional(),
567-
initialization: z.record(z.string(), z.any()).optional(),
551+
command: z.array(z.string()).optional(),
552+
environment: z.record(z.string(), z.string()).optional(),
553+
extensions: z.array(z.string()).optional(),
568554
}),
569-
]),
570-
)
555+
),
556+
])
557+
.optional(),
558+
lsp: z
559+
.union([
560+
z.literal(false),
561+
z.record(
562+
z.string(),
563+
z.union([
564+
z.object({
565+
disabled: z.literal(true),
566+
}),
567+
z.object({
568+
command: z.array(z.string()),
569+
extensions: z.array(z.string()).optional(),
570+
disabled: z.boolean().optional(),
571+
env: z.record(z.string(), z.string()).optional(),
572+
initialization: z.record(z.string(), z.any()).optional(),
573+
}),
574+
]),
575+
),
576+
])
571577
.optional()
572578
.refine(
573579
(data) => {
574580
if (!data) return true
581+
if (typeof data === "boolean") return true
575582
const serverIds = new Set(Object.values(LSPServer).map((s) => s.id))
576583

577584
return Object.entries(data).every(([id, config]) => {

packages/opencode/src/format/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export namespace Format {
2828
const cfg = await Config.get()
2929

3030
const formatters: Record<string, Formatter.Info> = {}
31+
if (cfg.formatter === false) {
32+
log.info("all formatters are disabled")
33+
return {
34+
enabled,
35+
formatters,
36+
}
37+
}
38+
3139
for (const item of Object.values(Formatter)) {
3240
formatters[item.name] = item
3341
}

packages/opencode/src/lsp/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,21 @@ export namespace LSP {
6262
async () => {
6363
const clients: LSPClient.Info[] = []
6464
const servers: Record<string, LSPServer.Info> = {}
65+
const cfg = await Config.get()
66+
67+
if (cfg.lsp === false) {
68+
log.info("all LSPs are disabled")
69+
return {
70+
broken: new Set<string>(),
71+
servers,
72+
clients,
73+
spawning: new Map<string, Promise<LSPClient.Info | undefined>>(),
74+
}
75+
}
76+
6577
for (const server of Object.values(LSPServer)) {
6678
servers[server.id] = server
6779
}
68-
const cfg = await Config.get()
6980
for (const [name, item] of Object.entries(cfg.lsp ?? {})) {
7081
const existing = servers[name]
7182
if (item.disabled) {

packages/sdk/js/src/gen/types.gen.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,33 +1117,37 @@ export type Config = {
11171117
mcp?: {
11181118
[key: string]: McpLocalConfig | McpRemoteConfig
11191119
}
1120-
formatter?: {
1121-
[key: string]: {
1122-
disabled?: boolean
1123-
command?: Array<string>
1124-
environment?: {
1125-
[key: string]: string
1126-
}
1127-
extensions?: Array<string>
1128-
}
1129-
}
1130-
lsp?: {
1131-
[key: string]:
1132-
| {
1133-
disabled: true
1134-
}
1135-
| {
1136-
command: Array<string>
1137-
extensions?: Array<string>
1120+
formatter?:
1121+
| false
1122+
| {
1123+
[key: string]: {
11381124
disabled?: boolean
1139-
env?: {
1125+
command?: Array<string>
1126+
environment?: {
11401127
[key: string]: string
11411128
}
1142-
initialization?: {
1143-
[key: string]: unknown
1144-
}
1129+
extensions?: Array<string>
11451130
}
1146-
}
1131+
}
1132+
lsp?:
1133+
| false
1134+
| {
1135+
[key: string]:
1136+
| {
1137+
disabled: true
1138+
}
1139+
| {
1140+
command: Array<string>
1141+
extensions?: Array<string>
1142+
disabled?: boolean
1143+
env?: {
1144+
[key: string]: string
1145+
}
1146+
initialization?: {
1147+
[key: string]: unknown
1148+
}
1149+
}
1150+
}
11471151
/**
11481152
* Additional instruction files or patterns to include
11491153
*/

0 commit comments

Comments
 (0)