From 13564f5517def1a9108af9e71149d10565472d18 Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Mon, 13 Nov 2023 20:58:58 +0100 Subject: [PATCH] Add autocommand for yank highlighting --- lua/valeth/options.lua | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lua/valeth/options.lua b/lua/valeth/options.lua index 59f6eb0..18e96b5 100644 --- a/lua/valeth/options.lua +++ b/lua/valeth/options.lua @@ -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 = " "