github saberzero1/motions 0.16.0

latest releases: 1.4.0, 1.3.1, 1.3.0...
3 months ago

Added

  • Cursor-aware table editing in Live Preview — replaced the table cell bridge approach with a custom table rendering system. Tables display as themed HTML when the cursor is outside and switch to raw Markdown when editing. All vim motions, operators, and text objects work naturally on table content. (#19)
    • Custom TableRenderWidget renders markdown tables as HTML using Obsidian's CSS classes (cm-embed-block, markdown-rendered, table-wrapper, table-cell-wrapper) for full theme compatibility
    • StateField provides Decoration.replace for tables the cursor is NOT in; removes decoration when cursor enters
    • Table widget suppressor patches RangeSetBuilder.prototype.add to suppress Obsidian's interactive table widget
    • Default mode: "Cursor-aware" — rendered table when cursor is outside, raw Markdown when editing
    • "Always raw" mode keeps tables as plain Markdown at all times
    • "Off" mode restores Obsidian's default interactive table editor
    • Three-way setting: Settings → Vim Motions → Table widget in live preview
    • Supports alignment markers (:---, ---:, :---:) in rendered tables
  • Vertical table cell navigation — ]r/[r moves to the same column in the next/previous row, skipping separator rows
  • Table cell text objects — i|/a| for operating on table cells with standard vim operators:
    • i|: content between surrounding pipes (like i()
    • a|: content plus the trailing pipe
    • Works with d, c, y, v: di| deletes cell content, ci| changes it, yi| yanks it
  • Table realignment — :tablerealign (short: :tablerea) ex command and <Leader>tr mapping. Computes column widths across all rows, pads cells uniformly, and respects :---/---:/:---: alignment markers in separator rows.
  • Table auto-format on | — CM6 inputHandler extension that realigns table columns when | is typed in insert mode. Typing || on a new line within a table generates a separator row (|---|---|).
  • Table manipulation keybindings — <Leader>t prefix commands mapped to Obsidian's built-in table commands, inspired by vim-table-mode:
    • <Leader>tm — insert table
    • <Leader>to/tO — add row below/above
    • <Leader>tJ/tK — move row down/up
    • <Leader>tdd — delete row
    • <Leader>tiL/tiH — add column right/left
    • <Leader>tL/tH — move column right/left
    • <Leader>tdc — delete column
    • <Leader>tr — realign table
  • Table ex commands — 15 ex commands for table manipulation: :tableinsert, :tablerowafter, :tablerowbefore, :tablerowup, :tablerowdown, :tablerowdelete, :tablecolafter, :tablecolbefore, :tablecolleft, :tablecolright, :tablecoldelete, :tablealignleft, :tablealigncenter, :tablealignright, :tablerealign
  • Internalized monkey-around — src/util/around.ts provides safe prototype patching with automatic removal, replacing the external monkey-around dependency
  • E2E test suite expansion: 28 tests in table-cell-bridge.e2e.ts (cursor-aware rendering, widget suppression, j/k navigation through tables, separator row traversal, post-edit navigation, theme class verification, alignment rendering), 24 tests in tables.e2e.ts (cell navigation, vertical navigation, text objects, realignment)

Fixed

  • Cursor stuck on table separator after insert-mode edit — after editing a table cell in insert mode, Obsidian's async table handler repositions the cursor, preventing k from crossing the separator row (|---|---|). Fixed with a custom tableAwareMoveUp motion that skips separator rows when moving up after a table edit. The motion detects the snap-back pattern and compensates by jumping two lines (over the separator) instead of one. Operator-pending context (dk) is excluded from the skip to preserve correct delete ranges.
  • Cursor-aware table rendering — the "Cursor-aware" mode now uses a custom read-only TableRenderWidget instead of Obsidian's interactive table widget. Tables render as themed HTML when the cursor is outside, with no async cursor snap-backs or state corruption.

Changed

  • Replaced TableCellBridge approach (per-cell vim bridge) with cursor-aware table rendering. The bridge approach required maintaining vim state across Obsidian's cell-scoped editors; the new system suppresses Obsidian's widget and provides its own themed read-only widget via a StateField.
  • tableWidgetMode setting default: 'cursor' (cursor-aware rendering)
  • Legacy suppressTableWidget: boolean setting migrated: true → 'always', false → 'off'

Documentation

  • KNOWN_LIMITATIONS.md: updated table navigation section with new features (vertical nav, text objects, realignment, auto-format); documented cursor-aware mode architecture
  • README.md: updated table navigation description for cursor-aware rendering; added i|/a| to text objects table, ]r/[r to navigation, table text objects section, auto-format docs, <Leader>tr and :tablerealign to commands

Full Changelog: 0.15.0...0.16.0

Don't miss a new motions release

NewReleases is sending notifications on new releases.