fix(bug): buffer-local keymap recreation and enhanced list content handling#102
Merged
YousefHadder merged 5 commits intomainfrom Nov 4, 2025
Merged
fix(bug): buffer-local keymap recreation and enhanced list content handling#102YousefHadder merged 5 commits intomainfrom
YousefHadder merged 5 commits intomainfrom
Conversation
- Fixed keymap_helper.lua to properly check for buffer-local mappings using maparg() instead of hasmapto() which was checking globally - This resolves autocomplete breaking after running :MarkdownPreview - Enhanced list item <CR> behavior to split content at cursor position - Added <S-CR> mapping to continue list content on next line without new bullet - All tests pass (168 successful), linting and formatting compliant
- Document <CR> split content at cursor feature - Document <A-CR> continue content without new bullet feature - Update keymap reference table with new <A-CR> binding - Add examples showing both new behaviors in action
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new "Shift+Enter" functionality for continuing list content on the next line without creating a new list item, while also improving the existing Enter key behavior to intelligently split list content at the cursor position.
- Introduces
handle_shift_enter()function that continues list content on a new line without adding a new bullet point - Enhances
handle_enter()to split list content when cursor is in the middle of a line, creating a new list item with the remaining text - Updates keymap registration logic to properly check for existing buffer-local mappings
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/markdown-plus/list/init.lua | Adds new keymap for Shift+Enter (<A-CR>) and exports the new handle_shift_enter function |
| lua/markdown-plus/list/handlers.lua | Implements handle_shift_enter() and modifies handle_enter() to support content splitting |
| lua/markdown-plus/keymap_helper.lua | Changes keymap registration to use maparg() instead of hasmapto() for buffer-local mapping detection |
| doc/markdown-plus.txt | Documents the new Shift+Enter functionality and updates Enter key description |
| README.md | Adds usage examples for content splitting and continuation features |
- Fix off-by-one error in content split condition (col < #line - 1) - Simplify buffer-local mapping check (remove unnecessary table comparison) - Update comment to show variable checkbox states in examples - All tests pass, no regressions
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.
Description
This PR fixes issue #101 where autocompletion breaks after running
:MarkdownPreview, and adds enhanced list content handling features.Changes
🐛 Bug Fix: Keymap Recreation After markdown-preview (#101)
Problem: When
markdown-previewwas invoked and the user returned to the markdown buffer, theFileTypeautocmd would fire again but buffer-local keymaps (like<CR>) would not be recreated, breaking autocompletion.Root Cause: The
keymap_helper.luausedvim.fn.hasmapto()which checks globally for mappings. Since the<Plug>mappings were created globally but default keymaps were buffer-local, the check would fail on subsequentFileTypeevents.Solution: Changed to use
vim.fn.maparg()with buffer-local checking to properly detect if a buffer-local mapping exists before attempting to create one.Files Changed:
lua/markdown-plus/keymap_helper.lua: Usemaparg()instead ofhasmapto()for buffer-local mapping detection✨ Feature: Enhanced List Content Handling
Added two new behaviors for better list editing experience:
1.
<CR>(Enter) - Split Content at Cursor- This is some| content<CR>becomes:2.
<A-CR>(Alt+Enter) - Continue Content Without New Bullet- This is a longer list item that|<A-CR>becomes:- This is a longer list item that continues hereFiles Changed:
lua/markdown-plus/list/handlers.lua: Enhancedhandle_enter(), addedhandle_shift_enter()lua/markdown-plus/list/init.lua: Added new<A-CR>keymap and exported new functionREADME.md: Added examples and updated keymap reference tabledoc/markdown-plus.txt: Updated documentation and keymap descriptionsTesting
✅ All 168 tests pass
✅ Linting passes with 0 warnings
✅ Formatting compliant with stylua
✅ No breaking changes to existing functionality
Compatibility
The new list behaviors work with:
-,*,+)1.,2., etc.)a.,b., etc.)- [ ],- [x])1),a), etc.)Fixes
Closes #101
Closes #100