Skip to content

Configuration

slang-format reads JSON configuration from .slang/format.json. It searches upward from each file independently, then from the current working directory. An explicit --config <path> or --config-json '<json>' takes precedence. These options cannot be combined; omitted settings use built-in defaults.

To configure formatting without a file:

slang-format --config-json '{"columnLimit":80,"indentWidth":2}' file.sv

All options are optional. Run slang-format --dump-config to print the resolved configuration for the first target (or stdin's assumed filename). Unknown keys are errors, including keys inside nested objects. Nested configs replace parent configs; omitted options use built-in defaults. Directory selection (projectPaths and excludeDirectoryNames) uses each directory argument's config; each file then resolves its own formatting settings.

projectPaths entries resolve from the project root containing .slang/. For example, src in project/.slang/format.json selects project/src when project is targeted.

Config Options

indentWidth

Type: integer

Default: 4

Number of spaces per indentation level (0-64)

columnLimit

Type: integer

Default: 100

Column limit for line wrapping (0 = no limit, maximum 1000000)

spacesBeforeTrailingComment

Type: integer

Default: 2

Number of spaces before trailing comments (0-256)

maxSyntaxDepth

Type: integer

Default: 512

Maximum syntax tree depth and parser recursion budget (must be positive). Files exceeding the limit are skipped unchanged, even with --force. Raising this limit increases stack usage and can cause stack overflow

alignment

Type: AlignConfig

Alignment padding and group separation

excludeDirectoryNames

Type: list[string]

Default: []

Exact directory names to skip during recursive file collection, at any depth. These are names, not paths or glob patterns. Explicit file and directory arguments are still processed

projectPaths

Type: list[string]

Default: []

File or directory paths relative to the project root containing .slang/. When that root is targeted, collect files only from these paths; an empty list collects the whole tree. Ignored for explicit file or subdirectory targets, with --config or --config-json, or when configuration is found only via the current-directory fallback. Missing paths produce a warning

alignment.paddingLimit

Type: integer | null

Alignment padding threshold in spaces. Split a group when adding a row would require this many or more spaces of padding; do not apply padding at or above the threshold. null disables the limit

alignment.statementGapLines

Type: integer

Default: 1

Number of existing separator lines required to split an alignment group of assignment statements or standalone variable, net, and parameter declarations. Empty lines count once; a standalone N-line comment region counts N-1. Does not insert lines; values below 1 use 1.

alignment.listGapLines

Type: integer

Default: 2

Number of existing separator lines required to split an alignment group of ports, parameter ports, connections, case items, struct fields, assignment-pattern fields, and other non-statement rows. Empty lines count once; a standalone N-line comment region counts N-1. Does not insert lines; values below 1 use 1.