This commit is contained in:
Dezly Macauley 2024-03-09 13:35:36 -08:00 committed by GitHub
commit b79c10164f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -190,14 +190,26 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
-- [[ Basic Autocommands ]] -- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands` -- See `:help lua-guide-autocommands`
-- NOTE: Displays colored highlight when you copy or delete text in Neovim
-- Highlight when yanking (copying) text -- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode -- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()` -- See `:help vim.highlight.on_yank()`
-- Choose your own highlight color: value in hexidecimals
local highlight_color = '#40005b'
-- Define how long the highlight should appear: value is in milliseconds
local highlight_timeout = 300
-- Create autocommand for highlighting yanked text
vim.api.nvim_create_autocmd('TextYankPost', { vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text', desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function() callback = function()
vim.highlight.on_yank() -- Set highlight color and timeout
vim.cmd(string.format('highlight YankHighlight guibg=%s ctermbg=0', highlight_color))
vim.highlight.on_yank { higroup = 'YankHighlight', timeout = highlight_timeout }
end, end,
}) })