mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-05 00:44:54 +01:00
allow disabling formatter
This commit is contained in:
@@ -278,6 +278,14 @@ export namespace Config {
|
|||||||
.optional()
|
.optional()
|
||||||
.describe("Custom provider configurations and model overrides"),
|
.describe("Custom provider configurations and model overrides"),
|
||||||
mcp: z.record(z.string(), Mcp).optional().describe("MCP (Model Context Protocol) server configurations"),
|
mcp: z.record(z.string(), Mcp).optional().describe("MCP (Model Context Protocol) server configurations"),
|
||||||
|
formatter: z
|
||||||
|
.record(
|
||||||
|
z.string(),
|
||||||
|
z.object({
|
||||||
|
disabled: z.boolean().optional(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"),
|
instructions: z.array(z.string()).optional().describe("Additional instruction files or patterns to include"),
|
||||||
layout: Layout.optional().describe("@deprecated Always uses stretch layout."),
|
layout: Layout.optional().describe("@deprecated Always uses stretch layout."),
|
||||||
permission: z
|
permission: z
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Log } from "../util/log"
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
|
|
||||||
import * as Formatter from "./formatter"
|
import * as Formatter from "./formatter"
|
||||||
|
import { Config } from "../config/config"
|
||||||
|
|
||||||
export namespace Format {
|
export namespace Format {
|
||||||
const log = Log.create({ service: "format" })
|
const log = Log.create({ service: "format" })
|
||||||
@@ -28,9 +29,11 @@ export namespace Format {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getFormatter(ext: string) {
|
async function getFormatter(ext: string) {
|
||||||
|
const cfg = await Config.get()
|
||||||
const result = []
|
const result = []
|
||||||
for (const item of Object.values(Formatter)) {
|
for (const item of Object.values(Formatter)) {
|
||||||
if (!item.extensions.includes(ext)) continue
|
if (!item.extensions.includes(ext)) continue
|
||||||
|
if (cfg.formatter?.[item.name]?.disabled) continue
|
||||||
if (!(await isEnabled(item))) continue
|
if (!(await isEnabled(item))) continue
|
||||||
result.push(item)
|
result.push(item)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user