Add yank highlighting
This commit is contained in:
parent
727c27e9a2
commit
6535fc31eb
1 changed files with 23 additions and 1 deletions
|
|
@ -1,3 +1,22 @@
|
||||||
|
|
||||||
|
local function setup_yank_highlight()
|
||||||
|
-- Create a new highlight group which will be used for yank highlighting with the name "YankHighlight"
|
||||||
|
vim.cmd("highlight YankHighlight guibg=#e0af68")
|
||||||
|
|
||||||
|
-- Create an autocommand group called "YankHighlight" and clear it
|
||||||
|
local yank_autocommand = vim.api.nvim_create_augroup("YankHighlightAutocommand", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
|
callback = function()
|
||||||
|
vim.highlight.on_yank({
|
||||||
|
timeout = 250,
|
||||||
|
higroup = "YankHighlight",
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
group = yank_autocommand,
|
||||||
|
pattern = "*",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- Load keymaps before loading any plugins
|
-- Load keymaps before loading any plugins
|
||||||
require("keymaps")
|
require("keymaps")
|
||||||
|
|
||||||
|
|
@ -9,3 +28,6 @@ require("lazy_init")
|
||||||
|
|
||||||
-- Initialize plugins, add a plugin by creating a new file in the plugins dir
|
-- Initialize plugins, add a plugin by creating a new file in the plugins dir
|
||||||
require("lazy").setup("plugs")
|
require("lazy").setup("plugs")
|
||||||
|
|
||||||
|
-- See ":help vim.highlight.on_yank()"
|
||||||
|
setup_yank_highlight()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue