Closed dnastase closed 2 weeks ago
Hi @dnastase --
Neovim:
If you are using neovim, you can use the following to fade the background color on a per window basis:
hi NormalNC guibg=black
If you want to combine vimade with the background changes above, the following should follow the same behaviors as vimade for which buffers get faded:
let start_win=win_getid()
hi NormalNC guibg=black
augroup startup
au!
au WinEnter * setlocal winhighlight=NormalNC:Normal
augroup END
silent windo setlocal winhighlight=NormalNC:Normal
silent windo echo ""
call win_gotoid(start_win)
Vim: If you are using vim, I think the right approach now is using wincolor. Vimade doesn't currently support detecting the background through wincolor for text fading, but if you need this let me know and it would be pretty quick to add.
On the config for vim side it could look like this:
function! SetBackground(target)
let l:wins=win_findbuf(bufnr())
let l:start_win=win_getid()
for l:win in l:wins
let l:winnr = win_id2win(l:win)
call setwinvar(l:winnr, "&wincolor", a:target)
endfor
endfunction
let start_win=win_getid()
hi NormalNC guibg=black
augroup startup
au!
au BufEnter * call SetBackground('Normal')
au BufLeave * call SetBackground('NormalNC')
augroup END
silent windo set wincolor=NormalNC
silent windo echo ""
call win_gotoid(start_win)
silent set wincolor=Normal
Yes, I think it would be useful to add to Vimade as it will allow text to be easy to read both on active and non-active buffers. My use case scenario is for coding where fading the text itself on the non-active buffers makes it hard to see source code that you need to reference in order to write the code in the active buffer. Having just the background change in the non-active buffers would keep the text as readable.
Thank you for the above, I will try it as soon as possible.
This is now included for both Vim (with wincolor support) and Neovim. Also added this into README
Example:
let g:vimade.ncmode = 'buffers'
let g:vimade.tint = {'bg': {'rgb': [0,0,0], 'intensity': 0.3}}
This lets you change the inactive background for all buffers. You can still use NormalNC if you prefer every window being different on Neovim. You can also use let g:vimade.ncmode='windows'
to have Vimade handle it for you.
Sorry, this is a question only, but I don't know where else to ask it.
First of all, nice plugin and very very useful to me ! thanks !
The question: when the focus moves, I can see the faded window changes the colors for the text, but the background remains the same. I would love to be able for the background to change too as that would be an even more visible difference. But I don't know how/if I can do that. Using the
g:vimade.basebg
only seems to change the tint of the text, not the background.