TaDaa / vimade

An eye friendly plugin that fades your inactive buffers and preserves your syntax highlighting!
MIT License
494 stars 9 forks source link

can I change the background for the faded window/buffer ? #53

Open dnastase opened 3 years ago

dnastase commented 3 years ago

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.

TaDaa commented 3 years 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
dnastase commented 3 years ago

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.