Skip to content

Formatter Options

Nick Kwiatkowski edited this page Nov 25, 2026 · 1 revision

Formatter Options

The formatting block controls the built-in formatter, used by textDocument/formatting, textDocument/rangeFormatting, on-type formatting, the clif.format command and clif format on the command line.

{
  "formatting": {
    "enabled": true,
    "selfCloseTags": true,
    "whitespaceOnly": true,
    "queryFormat": false,
    "lowercaseTags": true,
    "lowercaseAttributes": true,
    "doubleQuoteAttributes": true,
    "queryUppercaseKeywords": true,
    "parenSpacing": "pad",
    "braceStyle": "same-line",
    "blankLinesInBlocks": true,
    "switchCaseIndent": false,
    "scopeCase": "leave",
    "commaPosition": "after",
    "queryCommaPosition": "preserve",
    "lineWidth": 100,
    "paramBreakThreshold": 0,
    "attrBreakThreshold": 4,
    "indentWidth": 4
  }
}

General

Property Type Default Description
enabled boolean false Enable the formatter. When false, formatting requests are ignored. Omitting it leaves whatever the editor's settings said rather than switching the formatter off
whitespaceOnly boolean true Safety guard: reject results that change non-whitespace content (beyond the formatter's own canonicalisations; see The whitespace guard)
indentWidth integer 4 Spaces per indentation level. In the editor, overridden by the request's tabSize
lineWidth integer 100 Soft column limit; attributes and parameters expand onto separate lines past it
debug boolean false Enable formatter debug checks

Tags and attributes

Property Type Default Description Example
lowercaseTags boolean true Lowercase CF tag names. When false each tag keeps its own casing, opening and closing halves independently <CFOUTPUT> → <cfoutput>
lowercaseAttributes boolean true Lowercase attribute names NAME="x" → name="x"
doubleQuoteAttributes boolean true Normalise attribute values to double quotes name='x' → name="x"
selfCloseTags boolean true Convert void / implicit-end HTML tags to self-closing form <br> → <br />
attrBreakThreshold integer 4 Number of attributes above which they are always expanded onto separate lines —

CFScript layout

Property Type Default Values Description
braceStyle string "same-line" same-line, next-line same-line (K&R) keeps function f() {. next-line (Allman) puts the brace on its own line and moves else, catch, finally onto their own lines
parenSpacing string (unset) pad, tight pad: if ( a ), foo( 1, 2 ). tight: if (a), foo(1, 2). Unset pads conditions and grouping but not argument lists
blankLinesInBlocks boolean true — Pad a block's body with a blank line after { and before }. False gives compact blocks
switchCaseIndent boolean false — Indent case/default one level inside switch. False keeps labels at the switch column
commaPosition string "after" after, before Comma placement in multi-line argument lists (trailing / leading)
paramBreakThreshold integer 0 — Parameters above which a declaration's parameter list is expanded. 0 expands every list that has parameters; a list at or below the threshold still expands past lineWidth or when it holds a comment or trailing comma
scopeCase string "leave" upper, lower, leave Case for CFML scope names (variables, arguments, …)

braceStyle example

same-line:

if ( ok ) {
    run();
} else {
    stop();
}

next-line:

if ( ok )
{
    run();
}
else
{
    stop();
}

commaPosition example

after:

foo(
    alpha,
    beta
);

before:

foo(
    alpha
    , beta
);

Queries (<cfquery>)

Property Type Default Values Description
queryFormat boolean false — Format <cfquery> content (SQL re-indentation, keyword casing). When false, query content is emitted verbatim
queryUppercaseKeywords boolean true — Uppercase SQL keywords (with queryFormat)
queryCommaPosition string "preserve" preserve, after, before Comma placement in SQL SELECT lists

Editor-supplied options

These come from the editor's FormattingOptions on each request, not from the config:

Editor option Honoured Notes
tabSize ✔ Overrides indentWidth
insertSpaces / useTabs ✔ Tabs vs spaces
insertFinalNewline ✔ LSP 3.15
trimFinalNewlines ✔ LSP 3.15. A client sending neither gets exactly one trailing newline
trimTrailingWhitespace ✘ Deliberately not honoured: output is rebuilt from the syntax tree and never has trailing whitespace

Related switches

Switch Effect
features.rangeFormatting A second gate under formatting.enabled for Format Selection only; format-on-save keeps working when it is off
features.outputContextInterpolation Changes how #…# is read in tag files, which affects formatting of those regions

← LSP Initialization Options · Home

Clone this wiki locally