Skip to content

feat(format): preserve pipe table rows#130

Merged
barrettruth merged 1 commit intomainfrom
feat/pipe-table-preservation
Apr 4, 2026
Merged

feat(format): preserve pipe table rows#130
barrettruth merged 1 commit intomainfrom
feat/pipe-table-preservation

Conversation

@barrettruth
Copy link
Copy Markdown
Owner

Closes #129.

Summary

  • Add is_pipe_table_row heuristic to the formatter: lines that start and end with | (after trimming trailing whitespace) are preserved verbatim
  • Both the reflow entry point and the emit_prose_paragraph collector now skip pipe table rows
  • Covers padded (| cell | cell |) and tight (|cell|cell|) GFM-style tables
  • Add 5 unit tests: padded, tight, adjacent prose isolation, idempotency, and prose-after-table reflow
  • Update site docs: formatter.mdx (preserves list) and grammar.mdx (new Pipe Tables section)

Context

The formatter was destroying every GFM pipe table in any vimdoc file — fzf-lua's 207 table lines were reflowed into unreadable garbage. The root cause: pipe table rows are unindented, tab-free LineKind::Text lines, so they hit the prose reflow path.

The heuristic has zero false positives on the combined Neovim (135 files) and Vim (155 files) runtime corpus. The only | -prefixed lines in those docs are inside code blocks (already protected) or short taglink-only lines that don't need reflow.

Traditional vimdoc tables (tab-aligned columns with ~ headers) were already safe — the existing contains('\t') check handles them.

Test plan

  • cargo fmt --check passes
  • cargo clippy -- -D warnings passes
  • cargo test — all 142 tests pass (71 unit + 3 corpus + 7 format CLI + 50 integration + 11 server)
  • prettier --check site/ passes
  • Formatter on fzf-lua doc: zero table lines changed (was 498 lines mangled before)

Problem: The formatter treats GFM-style pipe table rows as prose and
reflows them into unreadable garbage. Any vimdoc file using markdown
tables (e.g. fzf-lua, panvimdoc-generated docs) is destroyed on format.

Solution: Add `is_pipe_table_row` check — lines that start and end with
`|` are preserved verbatim, skipping both the reflow entry point and the
paragraph collector. Covers padded (`| cell |`) and tight (`|cell|`)
styles. Zero false positives on the Neovim/Vim runtime corpus (290
files); the only `| `-prefixed lines in those docs are inside code
blocks or are short taglink-only lines that don't need reflow.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vimdoc-language-server Ready Ready Preview, Comment Apr 4, 2026 4:48pm

@barrettruth barrettruth merged commit 74a1e12 into main Apr 4, 2026
10 checks passed
@barrettruth barrettruth deleted the feat/pipe-table-preservation branch April 4, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(format): tables completely broken

1 participant