mirror of
https://github.com/preservim/vim-thematic.git
synced 2025-11-16 05:43:50 -05:00
improved color mute/fixes
This commit is contained in:
@@ -162,11 +162,13 @@ For console or GUI-based Vim:
|
||||
configured via background
|
||||
* `airline-theme` - plugin for theming your status bar
|
||||
* `sign-column-color-fix` - temporarily modifies colorscheme to force
|
||||
gutter background
|
||||
gutter background to match Normal background
|
||||
* `diff-color-fix` - temporarily modifies colorscheme to force diff
|
||||
character color
|
||||
character color to a standard red/green/yellow
|
||||
* `fold-column-color-mute` - temporarily modifies colorscheme to hide
|
||||
indicators in foldcolumn
|
||||
indicators, matching Normal text background
|
||||
* `number-column-color-mute` - temporarily modifies colorscheme to hide
|
||||
numbers, matching Normal text background
|
||||
|
||||
The following options are for GUI-based Vim only (they will be ignored if
|
||||
you're running a console-based Vim):
|
||||
@@ -181,7 +183,7 @@ Screen-related:
|
||||
|
||||
* `fullscreen` - if 1, force a switch to fullscreen
|
||||
* `fullscreen-background-color-fix` - optional change of color of the
|
||||
background (or border) to match text background
|
||||
background (or border) to match Normal text background
|
||||
* `columns` and `lines` - you’ll mostly use these to manage the height
|
||||
and width the text area in `fullscreen` mode
|
||||
* `transparency` (0=opaque, 100=fully transparent) - view details of
|
||||
|
||||
@@ -9,6 +9,40 @@
|
||||
if exists("autoloaded_thematic") | finish | endif
|
||||
let autoloaded_thematic = 1
|
||||
|
||||
function! s:normalColors(hi_grps)
|
||||
call s:setColorsTo(a:hi_grps, 'Normal', 'fg', 'bg')
|
||||
endfunction
|
||||
|
||||
function! s:invertColors(hi_grps)
|
||||
call s:setColorsTo(a:hi_grps, 'Normal', 'bg', 'fg')
|
||||
endfunction
|
||||
|
||||
function! s:muteColors(hi_grps)
|
||||
call s:setColorsTo(a:hi_grps, 'Normal', 'bg', 'bg')
|
||||
endfunction
|
||||
|
||||
function! s:setColorsTo(hi_grps, target_grp, target_fg, target_bg)
|
||||
" modify the specified highlight groups based on another highlight group
|
||||
if has('gui_running')
|
||||
for l:hi_grp in a:hi_grps
|
||||
execute 'hi! ' . l:hi_grp . ' guifg=' . a:target_fg . ' guibg=' . a:target_bg
|
||||
endfor
|
||||
else
|
||||
" set the cterm colors iff colorscheme specifies fg and bg
|
||||
" 'desert' does not, but 'bubblegum' does
|
||||
let l:target_grp_fg = synIDattr(synIDtrans(hlID(a:target_grp)), 'fg')
|
||||
let l:target_grp_bg = synIDattr(synIDtrans(hlID(a:target_grp)), 'bg')
|
||||
let l:ok_fg = l:target_grp_fg !~ '^-1$\|^$'
|
||||
let l:ok_bg = l:target_grp_bg !~ '^-1$\|^$'
|
||||
if l:ok_fg && l:ok_bg
|
||||
for l:hi_grp in a:hi_grps
|
||||
let l:nu_fg = a:target_fg ==# 'fg' ? l:target_grp_fg : l:target_grp_bg
|
||||
let l:nu_bg = a:target_bg ==# 'bg' ? l:target_grp_bg : l:target_grp_fg
|
||||
execute 'hi! ' . l:hi_grp . ' ctermfg=' . l:nu_fg . ' ctermbg=' . l:nu_bg
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:getThemeName(mode)
|
||||
let l:avail_names = sort(keys(g:thematic#themes))
|
||||
@@ -94,7 +128,7 @@ function! s:airline(th)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! thematic#init(mode)
|
||||
function! thematic#init(mode) abort
|
||||
if len(g:thematic#themes) == 0
|
||||
echohl WarningMsg | echo 'No themes found.' | echohl NONE
|
||||
finish
|
||||
@@ -138,40 +172,39 @@ function! thematic#init(mode)
|
||||
endif
|
||||
|
||||
" ------ Fix/mute colors ------
|
||||
|
||||
|
||||
let l:gui_running = has('gui_running')
|
||||
|
||||
if thematic#getThemeValue(l:th, 'sign-column-color-fix', 0)
|
||||
" Ensure the gutter matches the text background
|
||||
if l:gui_running
|
||||
hi! SignColumn guifg=fg guibg=bg
|
||||
else
|
||||
hi! SignColumn ctermfg=fg ctermbg=bg
|
||||
endif
|
||||
" Ensure the gutter matches 'Normal' highlighting
|
||||
call s:normalColors(['SignColumn',])
|
||||
endif
|
||||
|
||||
if thematic#getThemeValue(l:th, 'diff-color-fix', 0)
|
||||
" Override diff colors
|
||||
" Override diff colors, in case the colorscheme's diff colors are awful
|
||||
" Use also to fix sign column colors
|
||||
if l:gui_running
|
||||
hi! DiffAdd guifg=darkgreen guibg=bg
|
||||
hi! DiffDelete guifg=darkorange guibg=bg
|
||||
hi! DiffChange guifg=darkyellow guibg=bg
|
||||
hi! DiffText guifg=fg guibg=bg
|
||||
hi! DiffAdd guifg=DarkGreen guibg=bg
|
||||
hi! DiffDelete guifg=DarkRed guibg=bg
|
||||
hi! DiffChange guifg=DarkYellow guibg=bg
|
||||
hi! DiffText guifg=DarkCyan guibg=bg
|
||||
else
|
||||
hi! DiffAdd cterm=bold ctermbg=bg ctermfg=119
|
||||
hi! DiffDelete cterm=bold ctermbg=bg ctermfg=167
|
||||
hi! DiffChange cterm=bold ctermbg=bg ctermfg=227
|
||||
hi! DiffText cterm=none ctermbg=fg ctermfg=fg
|
||||
call s:normalColors(['DiffAdd','DiffDelete','DiffChange','DiffText',])
|
||||
hi! DiffAdd ctermfg=DarkGreen
|
||||
hi! DiffDelete ctermfg=DarkRed
|
||||
hi! DiffChange ctermfg=DarkYellow
|
||||
hi! DiffText ctermfg=DarkCyan
|
||||
endif
|
||||
endif
|
||||
|
||||
if thematic#getThemeValue(l:th, 'fold-column-color-mute', 0)
|
||||
" Ensure the fold column is blank, for non-distracted editing
|
||||
if l:gui_running
|
||||
hi! FoldColumn guifg=bg guibg=bg
|
||||
else
|
||||
hi! FoldColumn cterm=bold ctermbg=bg ctermfg=bg
|
||||
endif
|
||||
call s:muteColors(['FoldColumn',])
|
||||
endif
|
||||
|
||||
if thematic#getThemeValue(l:th, 'number-column-color-mute', 0)
|
||||
" Ensure the number column is blank, for non-distracted editing
|
||||
call s:muteColors(['LineNr', 'CursorLineNr',])
|
||||
endif
|
||||
|
||||
" ------ Set statusline, ruler, airline_theme ------
|
||||
|
||||
@@ -145,7 +145,7 @@ function! s:setGuifont(gf)
|
||||
endfunction
|
||||
|
||||
|
||||
function! thematic#gui#setFont(th)
|
||||
function! thematic#gui#setFont(th) abort
|
||||
" attempt to preserve original font if not yet set
|
||||
if !has_key(g:thematic#original, 'typeface')
|
||||
let l:typeface = s:getTypeface(&guifont, '')
|
||||
@@ -171,7 +171,7 @@ function! thematic#gui#setFont(th)
|
||||
endfunction
|
||||
|
||||
|
||||
function! thematic#gui#setTransparency(th)
|
||||
function! thematic#gui#setTransparency(th) abort
|
||||
let l:tr = thematic#getThemeValue(a:th, 'transparency', -1)
|
||||
if l:tr > 100
|
||||
let l:tr = 100
|
||||
@@ -188,7 +188,7 @@ function! thematic#gui#setTransparency(th)
|
||||
endfunction
|
||||
|
||||
|
||||
function! thematic#gui#setLinespace(th)
|
||||
function! thematic#gui#setLinespace(th) abort
|
||||
let l:ls = thematic#getThemeValue(a:th, 'linespace', -1)
|
||||
if l:ls != -1
|
||||
try
|
||||
@@ -202,7 +202,7 @@ function! thematic#gui#setLinespace(th)
|
||||
endfunction
|
||||
|
||||
|
||||
function! thematic#gui#setFullscreen(th)
|
||||
function! thematic#gui#setFullscreen(th) abort
|
||||
if has('fullscreen')
|
||||
" Because it can be jarring to see fullscreen disable,
|
||||
" we'll only enable it.
|
||||
@@ -226,7 +226,7 @@ endfunction
|
||||
|
||||
" If no explicit settings on lines and columns in
|
||||
" either the theme or the defaults, then leave alone.
|
||||
function! thematic#gui#setColumnsAndLines(th)
|
||||
function! thematic#gui#setColumnsAndLines(th) abort
|
||||
let l:columns = thematic#getThemeValue(a:th, 'columns', 0)
|
||||
if l:columns > 0
|
||||
execute 'set columns=' . l:columns
|
||||
|
||||
@@ -13,7 +13,7 @@ let g:loaded_thematic_gui = 1
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! thematic#gui#init(...)
|
||||
function! thematic#gui#init(...) abort
|
||||
let l:th = a:0 ? a:1 : {}
|
||||
call thematic#gui#setFont(l:th)
|
||||
call thematic#gui#setTransparency(l:th)
|
||||
@@ -22,7 +22,7 @@ function! thematic#gui#init(...)
|
||||
call thematic#gui#setColumnsAndLines(l:th)
|
||||
endfunction
|
||||
|
||||
function! thematic#gui#initFullscreen()
|
||||
function! thematic#gui#initFullscreen() abort
|
||||
" Take control of fullscreen behavior from Vim, specifically to
|
||||
" override its default behavior of maximizing columns and lines
|
||||
" in fullscreen Vim.
|
||||
|
||||
Reference in New Issue
Block a user