I already have the initial idea
vim.api.nvim_create_autocmd('WinEnter', {
pattern = '*',
callback = function()
"normal color for background"
end,
})
vim.api.nvim_create_autocmd('WinLeave', {
pattern = '*',
callback = function(args)
"please dim the background for inactive window"
end,
})
And I also have this idea using vimscript
" source: https://www.reddit.com/r/vim/comments/d46ger/comment/f084pjk/
hi ActiveWindow guibg=#21242b
hi InactiveWindow guibg=#282c34
" Call method on window enter
augroup WindowManagement
autocmd!
autocmd WinEnter * call Handle_Win_Enter()
augroup END
" Change highlight group of active/inactive windows
function! Handle_Win_Enter()
setlocal winhighlight=Normal:ActiveWindow,NormalNC:InactiveWindow
endfunction
From the same reddit page we have:
That can be shortened. Because NormalNC
automatically applies to the “Non-Current” window, you don’t need a WinEnter
autocmd. Just use :set
instead of :setlocal
.
hi ActiveWindow ctermbg=None ctermfg=None guibg=#21242b
hi InactiveWindow ctermbg=darkgray ctermfg=gray guibg=#282c34
set winhighlight=Normal:ActiveWindow,NormalNC:InactiveWindow