fix(format): use global operatorfunc instead of buffer-local#133
Merged
YousefHadder merged 1 commit intomainfrom Nov 22, 2025
Merged
fix(format): use global operatorfunc instead of buffer-local#133YousefHadder merged 1 commit intomainfrom
YousefHadder merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the operatorfunc option was incorrectly set as buffer-local (vim.bo) instead of global (vim.o), which is required for the g@ operator to function properly in Neovim.
Key Changes
- Changed
vim.bo.operatorfunctovim.o.operatorfuncin two functions - Updated comments to reflect the corrected scope
Comments suppressed due to low confidence (2)
lua/markdown-plus/format/init.lua:70
- The
_toggle_format_with_repeatfunction lacks test coverage. Since other functions in format_spec.lua have extensive tests, this function should also be tested to ensure the operatorfunc mechanism and dot-repeat functionality work correctly.
function M._toggle_format_with_repeat(format_type, plug)
-- Save state for repeat
M._repeat_state.format_type = format_type
-- Set operatorfunc for the g@ operator
vim.o.operatorfunc = "v:lua.require'markdown-plus.format'._format_operatorfunc"
-- Register with repeat.vim if available
if plug then
M.register_repeat(plug)
end
-- Return g@l for linewise operation (operatorfunc will handle word detection)
return "g@l"
end
lua/markdown-plus/format/init.lua:86
- The
_clear_with_repeatfunction lacks test coverage. Since other functions in format_spec.lua have extensive tests, this function should also be tested to ensure the operatorfunc mechanism and clear formatting with dot-repeat functionality work correctly.
function M._clear_with_repeat(plug)
-- Set operatorfunc for the g@ operator
vim.o.operatorfunc = "v:lua.require'markdown-plus.format'._clear_operatorfunc"
-- Register with repeat.vim if available
if plug then
M.register_repeat(plug)
end
-- Return g@l for linewise operation (operatorfunc will handle word detection)
return "g@l"
end
|
|
||
| -- Set operatorfunc (buffer-local to avoid conflicts) | ||
| vim.bo.operatorfunc = "v:lua.require'markdown-plus.format'._format_operatorfunc" | ||
| -- Set operatorfunc for the g@ operator |
There was a problem hiding this comment.
[nitpick] The comment could better explain why global scope is required. Consider: -- Set operatorfunc globally (required by Vim for g@ operator to work correctly)
Suggested change
| -- Set operatorfunc for the g@ operator | |
| -- Set operatorfunc globally (required by Vim for g@ operator to work correctly; operatorfunc must be global, not buffer-local) |
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
Brief description of the changes.
Type of Change
Related Issues
Fixes #(issue number)
Testing
Checklist