1
0

Add autocommand for yank highlighting

This commit is contained in:
Patrick Auernig 2023-11-13 20:58:58 +01:00
parent f6b53b4956
commit 13564f5517

View File

@ -1,3 +1,6 @@
local augroup = vim.api.nvim_create_augroup
local aucmd = vim.api.nvim_create_autocmd
vim.opt.number = true
vim.opt.relativenumber = true
@ -17,14 +20,27 @@ vim.opt.foldlevelstart = 99
vim.opt.fillchars:append({ eob = "·" })
vim.api.nvim_create_autocmd({"InsertEnter", "InsertLeave", "BufEnter"}, {
-- yank to clipboard, requires wl-copy command or equivalent
vim.opt.clipboard:append("unnamedplus")
vim.g.mapleader = " "
augroup("valeth", { clear = true })
-- Temporarily highlight yanked text
aucmd("TextYankPost", {
group = "valeth",
callback = function()
vim.highlight.on_yank({ timeout = 500 })
end
})
-- Hide cursor line while in insert mode
aucmd({"InsertEnter", "InsertLeave", "BufEnter"}, {
group = "valeth",
callback = function(args)
local entered_insert_mode = args.event == "InsertEnter"
vim.opt.cursorline = not entered_insert_mode
end
})
-- yank to clipboard, requires wl-copy command or equivalent
vim.opt.clipboard:append("unnamedplus")
vim.g.mapleader = " "