From 6dc90947a5aa7580268090fecff3b6f7495caabf Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 12 Jul 2022 09:29:04 +0100 Subject: [PATCH] feat(nvim): only show cursorline on active buffer --- roles/neovim/files/lua/opdavies/options.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/roles/neovim/files/lua/opdavies/options.lua b/roles/neovim/files/lua/opdavies/options.lua index 1cc6b0f..90254fe 100644 --- a/roles/neovim/files/lua/opdavies/options.lua +++ b/roles/neovim/files/lua/opdavies/options.lua @@ -18,6 +18,22 @@ local function set_autocmd() "VimResized *", { command = ":wincmd =" } ) + + -- Cursorline highlighting control. + -- Only have it on in the current buffer. + local group = vim.api.nvim_create_augroup("CursorLineControl", { clear = true }) + local set_cursorline = function(event, value, pattern) + vim.api.nvim_create_autocmd(event, { + group = group, + pattern = pattern, + callback = function() + vim.opt_local.cursorline = value + end, + }) + end + set_cursorline("WinLeave", false) + set_cursorline("WinEnter", true) + set_cursorline("FileType", false, "TelescopePrompt") end local function set_filetypes()