Skip to content

Configurable indentation rules ([languages.<id>.indent]) have no effect — all custom patterns are ignored #2314

Description

@sinelaw

Version: fresh 0.4.0 (built from master @ 1b5d7f8c8)

The 0.4.0 headline feature "Configurable indentation rules per language via [languages.<id>.indent], including VS Code-style regex rules" (CHANGELOG 0.4.0; documented in docs/configuration/index.md → "Customize Auto-Indentation") does not work. A custom language's indent block is parsed enough that the language is recognized (its name shows in the status bar), but none of the five indent patterns take effect. Auto-indentation falls back to Fresh's built-in heuristics regardless of what the user configures.

Steps to reproduce

  1. Create a project dir, e.g. /tmp/indent-test/, with .fresh/config.json:
    {
      "languages": {
        "incend":  { "extensions": ["t1"], "tab_size": 4, "use_tabs": false,
                     "indent": { "increase_indent_pattern": "OPEN\\s*$" } },
        "decr":    { "extensions": ["t3"], "tab_size": 4, "use_tabs": false,
                     "indent": { "increase_indent_pattern": "OPEN\\s*$", "decrease_indent_pattern": "^\\s*CLOSE\\b" } },
        "indnext": { "extensions": ["t4"], "tab_size": 4, "use_tabs": false,
                     "indent": { "indent_next_line_pattern": "^\\s*HDR\\b" } },
        "dednext": { "extensions": ["t5"], "tab_size": 4, "use_tabs": false,
                     "indent": { "increase_indent_pattern": "COLON\\s*$", "dedent_next_line_pattern": "^\\s*RET\\b" } }
      }
    }
    (OPEN/CLOSE/HDR are deliberately non-bracket, non-colon tokens so they do not overlap Fresh's built-in heuristics — this isolates whether the custom rule fires.)
  2. From that dir: fresh --no-restore test.t1 (status bar confirms filetype incend, so the language entry loaded).
  3. Type foo OPEN, press Enter, type child.

Expected behavior

Per the docs, increase_indent_pattern matches the reference line, so the new line is one level deeper:

foo OPEN
    child

This mirrors VS Code's indentationRules.increaseIndentPattern (language-configuration.json), which Fresh's docs explicitly model.

Actual behavior

The new line is not indented — it inherits the reference line's indent only:

│ 1 │ foo OPEN
│ 2 │ child          ← still column 0, increase_indent_pattern ignored

The same negative result holds for every pattern (each tested in its own single-rule custom language, --no-restore, literal keystrokes, whitespace verified with capture-pane | cat -A):

Pattern Config (token) Input → Enter Expected Actual
increase_indent_pattern (end-anchored) OPEN\s*$ foo OPEN → Enter next line +1 level no change
increase_indent_pattern (start-anchored) ^\s*OPEN\b OPEN → Enter next line +1 level no change
decrease_indent_pattern ^\s*CLOSE\b type CLOSE on an indented line line dedents 1 level stays indented
indent_next_line_pattern ^\s*HDR\b HDR → Enter next line only +1 level no change
dedent_next_line_pattern ^\s*RET\b RET (on indented line) → Enter following line −1 level stays indented

Meanwhile, Fresh's built-in heuristics still fire for the same custom languages — a line ending in : indents the next line, and {/} indent/dedent — even when a custom indent block is present (so the custom block does not replace the built-in behavior either; it is simply not consulted). This is why the documented examples appear to work: increase_indent_pattern: "[\{\[\(]\s*$" and ":\s*$" coincide with built-in bracket/colon indentation, masking the defect. Use a token the built-in doesn't recognize (like OPEN) and nothing happens.

Confirmed at both config layers — project .fresh/config.json and user ~/.config/fresh/config.json — with the same result. self_close_pattern could not be observed because it only cancels increase_indent_pattern, which itself never fires.

Workaround

None for custom/unrecognized languages. For languages whose desired rules happen to coincide with Fresh's built-in bracket/colon indentation, the built-in behavior applies anyway (but is not configurable).


Search performed (no existing issue): increase_indent_pattern, indent rules languages, indentation rule custom language, auto-indent pattern ignored.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions