fix: replace BufModifiedSet with OptionSet for Neovim 0.11 compat#49
Conversation
Hajime-Suzuki
left a comment
There was a problem hiding this comment.
Thank you so much for the PR! Migrating off BufModifiedSet is the right move for Neovim 0.13.
One correction: BufModifiedSet wasn't removed in 0.11. It still works on stable 0.11/0.12. Removal is in neovim#35610 and only affects 0.13 nightly today.
Also, OptionSet modified only became reliable in 0.13 (same PR). On 0.11/0.12 it doesn't fire on edits, so this change would break modified-icon updates for stable users.
Could we keep a version guard?
if vim.fn.has("nvim-0.13") == 1 then
-- OptionSet modified
else
-- BufModifiedSet
end
Same approach as nvim-tree#3325 and barbar#668.
|
Thanks for the clarification — and thank you very much for vuffers.nvim! The version guard approach ( if vim.fn.exists("##BufModifiedSet") == 1 then
vim.api.nvim_create_autocmd({ "BufModifiedSet" }, {
pattern = "*",
group = constants.AUTO_CMD_GROUP,
callback = function(buffer)
if not buf_utils.is_valid_buf(buffer) then
return
end
logger.debug("BufModifiedSet", { buffer = buffer })
ui.update_modified_icon(buffer)
end,
})
else
vim.api.nvim_create_autocmd({ "OptionSet" }, {
pattern = "modified",
group = constants.AUTO_CMD_GROUP,
callback = function(buffer)
if not buf_utils.is_valid_buf(buffer) then
return
end
logger.debug("OptionSet modified", { buffer = buffer })
ui.update_modified_icon(buffer)
end,
})
end
|
|
Thank you so much for your contribution! 🙏 |
BufModifiedSet was removed in Neovim 0.11. Replacing with OptionSet pattern=modified which has been available since Vim 7.4.729 so no version guard is needed.