If you love transparent term, but your favourite vim color scheme doesn't
If you use Neovim, See transparent.nvim
Without vim-transparent (example color scheme is eva01)
With vim-transparent
I recommend to use Vim-Plug to manage plugins.
Plug 'tribela/vim-transparent'
The bad thing is something in vim may be not transparent, if you use vim plugins. You can use :filter /<pattern>/ hi
to find the highlight groups e.g. :filter /CocList/ hi
, and change it.
For example, I use these plugins, coc.nvim, lightline, rnvimr, fzf.vim, vim-deus.
💡 You can also use let g:transparent_groups_add
if you just want to add some groups, without overriding the defaults.
Plug 'tribela/vim-transparent'
" default
let g:transparent_groups = ['Normal', 'Comment', 'Constant', 'Special', 'Identifier',
\ 'Statement', 'PreProc', 'Type', 'Underlined', 'Todo', 'String',
\ 'Function', 'Conditional', 'Repeat', 'Operator', 'Structure',
\ 'LineNr', 'NonText', 'SignColumn', 'CursorLineNr', 'EndOfBuffer']
" Pmenu
let g:transparent_groups += ['Pmenu']
" coc.nvim
let g:transparent_groups += ['NormalFloat', 'CocFloating']
augroup transparent
autocmd VimEnter,ColorScheme * call MyTransparent()
augroup END
function! MyTransparent()
" Customize the highlight groups for transparency in here.
" CursorLine
"hi CursorLine ctermfg=NONE ctermbg=239 guibg=NONE guibg=#4e4e4e
" coc.nvim
"hi CocMenuSel ctermbg=239 guibg=#4e4e4e
endfunction
vim-deus
configs:
set t_Co=256
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Add `let s:ds.none = ['NONE', 'NONE']` to deus.vim.
let g:deus_sign_column = 'none'
"set background=dark " Setting dark mode
colorscheme deus
let g:deus_termcolors=256
Because of let g:transparent_groups += ['NormalFloat', 'CocFloating']
, floating windows are transparent. So add borders for those transparent floating windows. Input :CocConfig
to open the coc-settings.json
, and add the blew:
// `:h coc-config-float`
"suggest.floatConfig": {
"border": true
},
"diagnostic.floatConfig": {
"border": true
},
"signature.floatConfig": {
"border": true
},
"hover.floatConfig": {
"border": true
},
Make lightline transparent:
autocmd VimEnter * call SetupLightlineColors()
function SetupLightlineColors() abort
" transparent background in statusbar
let l:palette = lightline#palette()
" `let s:p.{mode}.{where} = [ [ {guifg}, {guibg}, {ctermfg}, {ctermbg} ], ... ]`
let l:palette.normal = {
\ 'left': [[ '#008080', 'NONE', 6, 'NONE' ]],
\ 'middle': [[ '#008080', 'NONE', 6, 'NONE' ]],
\ 'right': [[ '#008080', 'NONE', 6, 'NONE' ]],
\ }
let l:palette.inactive = l:palette.normal
let l:palette.visual = l:palette.normal
let l:palette.insert = l:palette.normal
let l:palette.replace = l:palette.normal
let l:palette.tabline = {
\ 'left': [[ '#0000ff', 'NONE', 12, 'NONE' ]],
\ 'tabsel': [[ '#008080', 'NONE', 6, 'NONE' ]],
\ 'middle': [[ 'NONE', 'NONE', 'NONE', 'NONE' ]],
\ 'right': [[ 'NONE', 'NONE', 'NONE', 'NONE' ]],
\ }
call lightline#colorscheme()
endfunction
" Comment out the `colorscheme`.
let g:lightline = {
"\ 'colorscheme': 'deus',
\ }
Rnvimr:
" Rnvimr background
":hi RnvimrNormal
" show draw border
let g:rnvimr_draw_border = 1
fzf.vim:
":echo g:fzf_colors
" transparent the gutter
let $FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS .. ' --color=gutter:-1'
lightline and vim-deus:
coc.nvim floating windows:
coc.nvim CocList:
Rnvimr:
Pmenu:
vim-transparent automatically transparent all of highlight settings.
You can disable it by :TransparentDisable
and re-enable it by :TransparentEnable