feat: Phase 3 - Complete missing tests and add <Plug> mappings#6
Merged
YousefHadder merged 4 commits intomainfrom Oct 21, 2025
Merged
feat: Phase 3 - Complete missing tests and add <Plug> mappings#6YousefHadder merged 4 commits intomainfrom
YousefHadder merged 4 commits intomainfrom
Conversation
- Add comprehensive tests for format module (22 tests) - Add comprehensive tests for links module (13 tests) - Increase test coverage from 66% to 100% (47 → 69 tests) - Implement 33 <Plug> mappings across all modules for full customization - Add smart keymap detection with vim.fn.hasmapto() - Maintain full backward compatibility with existing configs - Add comprehensive 'Customizing Keymaps' section to README - Add complete <Plug> mapping reference documentation - Create PHASE3_PROGRESS.md tracking document Breaking Changes: None All tests passing: 69/69 Linting: 0 warnings, 0 errors
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR completes Phase 3 by adding comprehensive test coverage for the format and links modules and implementing full keymap customization through <Plug> mappings. The changes increase test coverage from 66% to 100% and enable users to fully customize all 33 keybindings across the plugin's four main modules.
Key Changes:
- Added 35 new tests covering format and links module functionality
- Implemented
<Plug>mapping system with smart default keymap detection - Enhanced documentation with comprehensive keymap customization guide
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/markdown-plus/format_spec.lua | New test suite for format module pattern validation and buffer operations |
| spec/markdown-plus/links_spec.lua | New test suite for links module pattern matching and cursor detection |
| lua/markdown-plus/format/init.lua | Added <Plug> mappings and smart default keymap setup |
| lua/markdown-plus/headers/init.lua | Added <Plug> mappings with loop-based header level mapping |
| lua/markdown-plus/links/init.lua | Added <Plug> mappings for link operations |
| lua/markdown-plus/list/init.lua | Added <Plug> mappings for list management |
| README.md | Added comprehensive keymap customization documentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Remove requirement to fork repository - Users can now open issues and PRs directly to the repo - Update CONTRIBUTING.md with simplified workflow - Update README.md Contributing sections - Add note about optional forking - Encourage direct collaboration and community involvement
…ug> mappings
Visual mode keymaps were using string commands like:
':<C-u>lua require(...).function()<CR>'
This doesn't work properly in visual mode. Changed to use Lua functions:
function() M.toggle_format('bold') end
This fixes the issue where keymaps weren't working when the plugin was loaded.
- Fix Lua truthiness issue with vim.fn.hasmapto() - Changed 'if not vim.fn.hasmapto(...)' to 'if vim.fn.hasmapto(...) == 0' - In Lua, 0 is truthy, so 'not 0' evaluated to false - This bug prevented ALL default keymaps from being created - Add descriptions to all 37 default keymaps - Format: 'Toggle bold', 'Toggle italic', etc. - Headers: 'Next header', 'Set header level 1', etc. - Links: 'Insert link', 'Edit link', etc. - Lists: 'Continue list item', 'Indent list item', etc. - Fixed in 4 modules: format, headers, links, list - All tests passing (69/69) - Zero linting warnings/errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #4
Summary
This PR completes Phase 3 of the improvement plan by adding comprehensive tests and implementing full keymap customization via
<Plug>mappings.Changes
✅ 1. Complete Missing Tests
Added
spec/markdown-plus/format_spec.lua(22 tests):has_formatting()detection testsadd_formatting()andremove_formatting()testsget_text_in_range()andset_text_in_range()buffer operation testsAdded
spec/markdown-plus/links_spec.lua(13 tests):get_link_at_cursor()tests for different link typesfind_reference_url()tests for reference definitionsResults: Test coverage increased from 66% to 100% (47 → 69 tests)
✅ 2. Implement
<Plug>MappingsImplemented 33
<Plug>mappings across all modules:Key Features:
vim.fn.hasmapto()- only sets defaults if not already mappedkeymaps.enabled = false✅ 3. Enhanced Documentation
Added comprehensive "Customizing Keymaps" section to README.md (~150 lines):
<Plug>mapping reference (all 33 mappings)Quality Metrics
Impact
<Plug>mappings)Files Changed
New Files:
spec/markdown-plus/format_spec.lua(~180 lines)spec/markdown-plus/links_spec.lua(~230 lines)PHASE3_PROGRESS.md(~260 lines)Modified Files:
lua/markdown-plus/format/init.lua(+60 lines)lua/markdown-plus/headers/init.lua(+45 lines)lua/markdown-plus/links/init.lua(+35 lines)lua/markdown-plus/list/init.lua(+40 lines)README.md(+150 lines)Breaking Changes
None - All changes are fully backward compatible.
Related Issues
Closes Phase 3 tasks from IMPROVEMENT_PLAN.md:
<Plug>mappings for user customizationChecklist