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.
This commit is contained in:
Fernando Schauenburg 2022-02-14 18:31:54 +01:00
parent 2498e73c10
commit be90870000

View file

@ -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.