From be90870000c0685082b8ec91fe899fe2bb922fc4 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Mon, 14 Feb 2022 18:31:54 +0100 Subject: [PATCH] vim: fix loss of cursorline when using Telescope The issue was that 'cursorline' is a window option but I was storing the original value in global variable. So when Telescope (which has 'cursorline' not set in its window) entered insert mode, the InsertEnter autocmd caused the global variable to store 0 (nocursorline). After this, every InsertLeave event would use the global value and eventually disable the cursorline everywhere. --- config/nvim/lua/fs/autocmds.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/nvim/lua/fs/autocmds.lua b/config/nvim/lua/fs/autocmds.lua index 469ed8b..9cd72bb 100644 --- a/config/nvim/lua/fs/autocmds.lua +++ b/config/nvim/lua/fs/autocmds.lua @@ -17,9 +17,11 @@ make_autocmds { }, windows = { -- Disable cursorline when entering Insert mode (but remember it)... - { 'InsertEnter', '*', 'let g:stored_cursorline=&cursorline | set nocursorline' }, + { 'InsertEnter', '*', + [[let w:had_cursorline=&cursorline | set nocursorline]] }, -- ...and re-enable when leaving if it had been set before. - { 'InsertLeave', '*', 'let &cursorline=g:stored_cursorline' }, + { 'InsertLeave', '*', + [[if exists('w:had_cursorline') | let &cursorline=w:had_cursorline | endif]] }, }, yank = { -- Briefly highlight yanked text.