Dough Git

clove/code4dyslexia

SUPPORTED.md

back to tree

Supported languages and settings

Configuration

c4d config show creates ~/.c4d/config.jp from the bundled defaults if it is missing. Existing global settings keep their contents.

Use ~/.c4d/config.jp for global settings and <project-root>/.c4d/config.jp for project settings. C4D looks upward from each source directory for the nearest project file and stops at the Git root if it finds one first. A nested project config takes the project layer for files in its subtree.

Each setting inherits independently. From lowest to highest precedence

  1. Built-in defaults
  2. Global settings
  3. Global language override
  4. Project settings
  5. Project language override

Omit a key to inherit it. Set a formatting option to 0 to disable that transformation, or a naming option to disabled to turn off its check. Formatting sizes are integers from 0 to 100. Invalid configuration reports the file and, for JPCL syntax errors, the parser's line and column.

The official JPCL parser accepts bare setting values, [section] headers, nested objects, line comments beginning with ~~, and block comments wrapped in ~* and *~. The following default file is embedded in the executable.

~* Default configuration for code4dyslexia
   (c) MIT - Clove Twilight 2026
   https://github.com/doughmination/code4dyslexia
*~

[terminal]
color: default

[formatting]
~~ Set any of these to 0 to disable them
indentSize: 4
newLineSize: 2
~~ Enable to add a file path comment automatically
filePathHeader: false

[cases]
~* Accepted values:
   flatcase - acoolfunction
   camelCase - aCoolFunction
   PascalCase - ACoolFunction
   snake_case - a_cool_function
   SCREAMING_SNAKE_CASE - A_COOL_FUNCTION
   disabled - Disables checks
*~
functions: disabled
variables: disabled
classes: disabled

~~ Uncomment the override block to customise individual languages

~*
[overrides]
typescript: {
    formatting: {
        newLineSize: 3
    }
    cases: {
        functions: camelCase
    }
}
*~

The commented TypeScript example is valid JPCL and can be inspected when enabled. Language overrides for an adapter that has yet to be implemented have no effect on file processing. To configure the Rust adapter, use the rust language identifier.

[overrides.rust.formatting]
newLineSize: 3

[overrides.rust.cases]
functions: snake_case

Terminal colours

Choose a theme in global or project JPCL settings.

[terminal]
color: catppuccin
ThemeAppearance
default or normalStandard terminal colours. This is the default.
pastelSoft teal, lilac, and rose accents.
catppuccinGreen, yellow, and red from Catppuccin Mocha.
protanopia, protanomaly, deuteranopia, deuteranomalyBlue and amber accents for red–green colour vision differences.
tritanopia, tritanomalyGreen and pink accents for blue–yellow colour vision differences.
achromatopsia, blue-cone-monochromacy, monochromeBold and underlined labels without colour.
plainPlain text.

Themes style rule names and formatting status labels. Those labels remain readable in plain text. Redirected output, configuration output, TERM=dumb, and a non-empty NO_COLOR environment variable all produce plain text. The RGB themes work best in a true-colour terminal. To choose a theme for Rust specifically, set color under [overrides.rust.terminal].

Supported sources

Extensions are case-insensitive. Use the language identifier under [overrides].

LanguageExtensionsTool needed
Rust.rsBuilt in
JSON.jsonBuilt in
JSONC.jsoncBuilt in
Python.py, .pyiCPython 3.11+
Go.goGo 1.21+
TypeScript.ts, .mts, .ctsNode.js and the TypeScript 6 compiler package
JavaScript.js, .mjs, .cjsNode.js and the TypeScript 6 compiler package
Lua.lualuac on PATH

Rust

The Rust adapter uses syn for the syntax tree and proc-macro2 for source token spans.

Rust formatting

  • indentSize controls leading spaces on lines that begin with a token. Each active multiline brace, bracket, or parenthesis group contributes one level. Nested groups opened on the same line share a level. A line that begins with a closing delimiter uses the enclosing level.
  • newLineSize counts newline sequences between sibling items or statements already on separate lines, where at least one sibling is a logical block. Logical blocks include functions, structs, enums, unions, impls, traits, modules, and extern blocks. At statement level they also include standalone blocks and control-flow expressions such as if, match, and loops. C4D edits gaps made entirely of whitespace and uses the first newline sequence in the gap. A size of 2 gives one empty line.
  • By default, formatting edits only leading indentation and qualifying gaps. Literals, comments, macro arguments, and attribute contents keep their bytes. Files containing explicit line!() or column!() calls retain all source positions. Checks still report naming issues in those files.

The syntax check is based on the parser available in the pinned version of syn. It does not type-check, resolve names, evaluate configuration attributes, or expand macros. Some macro-expanded code and compiler features are opaque to the tool. Formatting can shift source locations observed indirectly through macros, compiler diagnostics, or caller metadata.

File path headers

Enable this option in .c4d/config.jp to have c4d format add a comment such as // src/main.rs. The option defaults to false.

[formatting]
filePathHeader: true

C4D uses the path relative to the project root, or the working directory when there is no project root. Files outside both use their basename. The comment goes after a byte-order mark or shebang when present. An exact matching path in the leading comments counts as an existing header. c4d check reports missing headers and c4d format --check previews them. Files with explicit line!() or column!() calls also skip header insertion.

Rust naming

OptionRust declarations checked
functionsNamed functions and method signatures
variablesPattern bindings, including function parameters, and named const and static items
classesStructs, enums, unions, and traits

All checks are disabled by default. With a check enabled, names are matched against that convention's ASCII letters, digits, and underscore pattern. A Rust raw identifier prefix r# is ignored for matching. Diagnostics never change the identifier.

JSON and JSONC

C4D validates files before applying whitespace edits. JSON uses strict JSON syntax. JSONC also accepts line comments, block comments, and trailing commas. The extension selects the syntax. A .json file containing comments reports a syntax error.

  • indentSize sets the leading spaces per open object or array. A line that starts with a closing delimiter uses the enclosing level.
  • newLineSize applies between siblings on separate lines when either value is an object or array. A gap containing a comment is left intact.
  • Strings, number spellings, duplicate keys, key order, and comment contents keep their original bytes. The JSON adapters skip file path headers and naming checks.

Python

Python formatting requires CPython 3.11 or newer as python3 on PATH. C4D uses it to parse and tokenize source without executing it. The installed Python version determines which syntax is supported. The adapter accepts UTF-8 source with LF or CRLF line endings.

  • indentSize sets spaces per indentation level on logical statement lines. Continuation lines, comments, and multiline string contents keep their original spacing.
  • newLineSize sets the spacing between statements in the same suite when either is a compound statement such as a definition, loop, or conditional. Gaps containing comments keep their existing spacing.
  • filePathHeader adds a # path/to/file.py comment after any shebang and encoding declaration.
  • Naming checks cover function and class definitions, parameters, and simple name bindings. Checks report diagnostics without renaming anything.

Before writing, C4D reparses the proposed result and compares the two syntax trees. Formatting can still shift source line numbers used by tracebacks or inspection tools.

Go

Go formatting requires Go 1.21 or newer as go on PATH. C4D starts one helper per invocation using Go's standard parser and scanner. The helper builds locally with the installed toolchain and uses its normal build cache. C4D parses the source without building or executing the Go files you pass in.

  • indentSize sets spaces per open brace, bracket, or parenthesis. Lines beginning with a closing delimiter use the enclosing level.
  • newLineSize applies between sibling declarations or statements on different lines when one is a logical block. These include functions, type declarations, grouped declarations, loops, conditionals, switches, selects, and standalone blocks. Gaps with comments keep their spacing.
  • filePathHeader inserts a standalone // path/to/file.go comment above the source. Files with Go line directives keep their position and spacing.
  • Naming checks cover functions and methods, named types, named parameters and results, const and var declarations, and names on the left of :=.

Before writing, C4D reparses the result and compares token kinds and spellings, including implicit semicolons. Literals and existing comments keep their bytes. Syntax checking uses Go's parser and skips package type checking.

TypeScript and JavaScript

Install the trusted typescript@6 package where Node can resolve it, or set C4D_TYPESCRIPT to the absolute path to its lib/typescript.js. For example, with the package installed in the current project:

C4D_TYPESCRIPT="$PWD/node_modules/typescript/lib/typescript.js" c4d check .

The identifiers are typescript and javascript. Both adapters support indentation, spacing between logical statement blocks, path headers, and naming diagnostics for functions, methods, classes, variables, and parameters. The adapter reparses edits and compares syntax tree structure and token text to protect template contents and automatic semicolon insertion. It parses source without running it or type-checking it. JSX and TSX are outside this initial adapter.

Lua

The lua adapter uses luac -p to validate source without executing it. The installed compiler determines the Lua version accepted. C4D adjusts indentation around block keywords and delimiters and can insert a -- path/to/file.lua header after a shebang. It preserves existing comments, long strings, and line endings, and validates the result before writing. Lua blank-line spacing and naming diagnostics are pending.

Discovery

Directories are traversed in name order. The tool skips symlinks, non-source files, and common dependency, cache, and build directories such as .git, node_modules, target, vendor, and dist. It also skips invalid UTF-8, files with NUL bytes, generated suffixes such as .generated.rs, and recognised generated markers in the leading comments. Add unusual generated paths to .c4dignore.

C4D reads ancestor and nested .gitignore and .c4dignore files. It supports ordinary Git-style path patterns, including anchors, directory-only patterns, wildcards, character ranges, escaped leading markers, and negation. Global Git excludes and .git/info/exclude are outside this first release.

Writes replace a changed file atomically and preserve its permission bits. On Unix, C4D rejects files with multiple hard links. It checks for changes to the source immediately before replacement. Avoid concurrent formatting and editing of the same file.

Contributing

Run cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, and cargo test --locked before submitting a change. The Python and Go integration tests use python3 and go respectively. The ECMAScript and Lua integration tests run when Node can load TypeScript and luac is available, respectively. When adding a language, register its adapter in src/language.rs and add representative fixtures covering syntax-sensitive whitespace, literals, comments, and repeat runs. Keep transformations constrained to the spans that the adapter can verify.

MIT licence.