Skip to content

feat(format): add dot-repeat support for normal mode formatting actions#132

Merged
YousefHadder merged 2 commits intomainfrom
feat/dot-repeat-formatting
Nov 21, 2025
Merged

feat(format): add dot-repeat support for normal mode formatting actions#132
YousefHadder merged 2 commits intomainfrom
feat/dot-repeat-formatting

Conversation

@YousefHadder
Copy link
Owner

Description

Implements dot-repeat support for normal mode formatting actions, allowing users to quickly apply the same formatting to multiple words using Vim's native . command.

Closes #131

Changes

Implementation

  • Added operatorfunc-based dot-repeat for normal mode formatting commands
  • Uses native Neovim g@l operator mechanism (no external dependencies)
  • Optional integration with repeat.vim if available
  • Visual mode formatting works normally (no dot-repeat by design)

Files Modified

  • lua/markdown-plus/format/init.lua - Core implementation with operatorfunc callbacks
  • lua/markdown-plus/keymap_helper.lua - Added expr mapping support
  • README.md - Added feature documentation with examples
  • doc/markdown-plus.txt - Updated help docs with usage guide

Usage Example

word1 word2 word3

1. Position cursor on "word1"
2. Press <leader>mb  →  **word1** word2 word3
3. Move cursor to "word2"
4. Press .  →  **word1** **word2** word3
5. Move to "word3", press .  →  **word1** **word2** **word3**

Supported Commands

All normal mode formatting actions are now dot-repeatable:

  • <leader>mb - Toggle bold
  • <leader>mi - Toggle italic
  • <leader>mc - Toggle inline code
  • <leader>ms - Toggle strikethrough
  • <leader>mC - Clear all formatting

Testing

  • ✅ All 94 existing tests pass
  • ✅ 0 linting errors
  • ✅ Code properly formatted
  • ✅ No breaking changes
  • ✅ No new configuration required

Technical Details

The implementation uses Neovim's operatorfunc mechanism:

  1. Normal mode mappings use expr = true and return "g@l"
  2. Format type is stored in internal state
  3. Operatorfunc callback applies the formatting
  4. Native . command repeats the operator

This works without any external plugins, though it remains compatible with repeat.vim for enhanced functionality.

Documentation

All documentation has been updated:

  • Feature description in README with concrete example
  • Detailed usage guide in vimdoc
  • Clear indication that visual mode doesn't support dot-repeat (by design)

Copilot AI review requested due to automatic review settings November 21, 2025 03:17
@YousefHadder YousefHadder changed the title feat: add dot-repeat support for normal mode formatting actions feat(format): add dot-repeat support for normal mode formatting actions Nov 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements dot-repeat support for normal mode formatting actions in markdown-plus.nvim, enabling users to quickly apply the same formatting to multiple words using Vim's native . command. The implementation uses Neovim's operatorfunc mechanism without requiring external dependencies.

Key Changes:

  • Added operatorfunc-based dot-repeat mechanism for formatting commands (bold, italic, strikethrough, code, clear formatting)
  • Extended keymap helper to support expression mappings with per-mode configuration
  • Updated documentation in README and vimdoc with usage examples

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
lua/markdown-plus/format/init.lua Implements dot-repeat functionality via operatorfunc callbacks and wrapper functions
lua/markdown-plus/keymap_helper.lua Adds support for expression mappings with per-mode expr flag
doc/markdown-plus.txt Documents dot-repeat feature with usage examples
README.md Adds dot-repeat feature description to feature list

@YousefHadder YousefHadder merged commit 300abe9 into main Nov 21, 2025
14 checks passed
@YousefHadder YousefHadder deleted the feat/dot-repeat-formatting branch November 21, 2025 03:36
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.

[FEATURE] Format actions should be dot-repeatable

1 participant