From d24a6ec16d7fb99b13b32473107a64d7d6380814 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:45:33 -0500 Subject: [PATCH] Highlight text when yanking --- home/neovim/extra-config.lua | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/home/neovim/extra-config.lua b/home/neovim/extra-config.lua index e2a353c..f647935 100644 --- a/home/neovim/extra-config.lua +++ b/home/neovim/extra-config.lua @@ -1,11 +1,20 @@ -- https://github.com/nvim-lua/kickstart.nvim/blob/master/init.lua -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - -vim.o.clipboard = 'unnamedplus' -vim.o.colorcolumn = '80' +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- clipboard +vim.o.clipboard = "unnamedplus" +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +vim.o.colorcolumn = "80" vim.o.cursorline = true -vim.o.inccommand = 'split' +vim.o.inccommand = "split" -- tabs vim.o.expandtab = true @@ -17,10 +26,10 @@ vim.o.tabstop = 2 vim.o.splitright = true vim.o.splitbelow = true -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +vim.keymap.set("n", "", "", { desc = "Move focus to the left window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the right window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the upper window" }) -- line numbers vim.o.number = true @@ -32,21 +41,21 @@ vim.o.ignorecase = true vim.o.smartcase = true -- arrows -vim.keymap.set('n', '', 'echo "Use h to move!!"') -vim.keymap.set('n', '', 'echo "Use l to move!!"') -vim.keymap.set('n', '', 'echo "Use k to move!!"') -vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set("n", "", 'echo "Use h to move!!"') +vim.keymap.set("n", "", 'echo "Use l to move!!"') +vim.keymap.set("n", "", 'echo "Use k to move!!"') +vim.keymap.set("n", "", 'echo "Use j to move!!"') -- https://twitter.com/theprimeagen/status/1591996471951429633 -vim.keymap.set('n', '', 'zz', {}) -vim.keymap.set('n', '', 'zz', {}) -vim.keymap.set('n', 'n', 'nzz', {}) +vim.keymap.set("n", "", "zz", {}) +vim.keymap.set("n", "", "zz", {}) +vim.keymap.set("n", "n", "nzz", {}) -- https://twitter.com/adib_hanna/status/1657074745978781701 -vim.keymap.set('n', 'j', 'jzz', {}) -vim.keymap.set('n', 'k', 'kzz', {}) +vim.keymap.set("n", "j", "jzz", {}) +vim.keymap.set("n", "k", "kzz", {}) -- https://github.com/ThePrimeagen/init.lua/blob/master/lua/theprimeagen/remap.lua -- https://vimtricks.com/p/vimtrick-moving-lines/ -vim.keymap.set('v', 'J', ":m '>+1gv=gv") -vim.keymap.set('v', 'K', ":m '<-2gv=gv") +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") -vim.keymap.set('n', '', 'nohlsearch') +vim.keymap.set("n", "", "nohlsearch")