feat(vim.hl): vim.hl.hl_op() #39777

Problem:
vim.hl.on_yank() only works for TextYankPost, not TextPutPost.

Solution:
Introduce hl_op().
Deprecate on_yank().
This commit is contained in:
Ayose C.
2026-05-17 13:56:37 +00:00
committed by GitHub
parent 8e1d6dfada
commit 3ace049c6a
6 changed files with 101 additions and 41 deletions

View File

@@ -60,11 +60,11 @@ vim.keymap.set({ 'n' }, '<A-l>', '<C-w>l')
-- See `:h lua-guide-autocommands`, `:h autocmd`, `:h nvim_create_autocmd()`
-- Highlight when yanking (copying) text.
-- Try it with `yap` in normal mode. See `:h vim.hl.on_yank()`
-- Try it with `yap` in normal mode. See `:h vim.hl.hl_op()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
callback = function()
vim.hl.on_yank()
vim.hl.hl_op()
end,
})