Skip to content

Commit

Permalink
feat: add srcery bg option (#104)
Browse files Browse the repository at this point in the history
Adds the new option g:srcery_bg, see documentation for use. This PR deprecates the option g:srcery_bg_passthrough, documentation updates follows

* Add option to set bg to hard_black for gui.

Srcery already has a vim-only option to set the terminal background to
hard_black. This commit adds another option, g:srcery_hard_black_gui_bg,
compatible with the termguicolors (both Vim and Neovim) set-option.

* Fix documenation.

* Add RGB background option.

* Improve background management with single option.

* Remove old variable.

* Fix 'DEFAULT' handling.

* Update autoload/srcery.vim

Co-authored-by: Daniel Berg <[email protected]>

* Resoved review issue.

---------

Co-authored-by: Daniel Berg <[email protected]>
  • Loading branch information
micangl and roosta authored Sep 23, 2023
1 parent 755e4ab commit 7fecf70
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 83 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ slightly earthy tone.
- [g:srcery\_bg\_passthrough](#gsrcery_bg_passthrough)
- [g:srcery\_guisp\_fallback](#gsrcery_guisp_fallback)
- [g:srcery\_italic\_types](#gsrcery_italic_types)
- [g:srcery\_bg](#gsrcery_bg)
- [g:srcery\_hard\_black\_terminal\_bg](#gsrcery_hard_black_terminal_bg)
- [Screenshots](#screenshots)
- [Plugin support](#plugin-support)
Expand Down Expand Up @@ -297,6 +298,13 @@ Italicize types if italic is enabled.

Default: 0

#### g:srcery\_bg

Background color, specified as an RGB value.
Note that this will only work with 'set termguicolors' in your config, and that it is mutually exclusive with 'g:srcery_hard_black_terminal_bg'.

Default: 'g:srcery_black'

#### g:srcery\_hard\_black\_terminal\_bg

If enabled, will set the terminal background in vim to hard black.
Expand Down
24 changes: 7 additions & 17 deletions after/syntax/html.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,12 @@ call srcery#helper#Highlight('htmlLink', s:bright_white, s:none, s:underline)

hi! link htmlSpecialChar SrceryYellow

if g:srcery_bg_passthrough == 1 && !has('gui_running')
call srcery#helper#Highlight('htmlBold', s:bright_white, s:none, s:bold)
call srcery#helper#Highlight('htmlBoldUnderline', s:bright_white, s:none, s:bold . s:underline)
call srcery#helper#Highlight('htmlBoldItalic', s:bright_white, s:none, s:bold . s:italic)
call srcery#helper#Highlight('htmlBoldUnderlineItalic', s:bright_white, s:none, s:bold . s:underline . s:italic)
call srcery#helper#Highlight('htmlUnderline', s:bright_white, s:none, s:underline)
call srcery#helper#Highlight('htmlUnderlineItalic', s:bright_white, s:none, s:underline . s:italic)
call srcery#helper#Highlight('htmlItalic', s:bright_white, s:none, s:italic)
else
call srcery#helper#Highlight('htmlBold', s:bright_white, s:black, s:bold)
call srcery#helper#Highlight('htmlBoldUnderline', s:bright_white, s:black, s:bold . s:underline)
call srcery#helper#Highlight('htmlBoldItalic', s:bright_white, s:black, s:bold . s:italic)
call srcery#helper#Highlight('htmlBoldUnderlineItalic', s:bright_white, s:black, s:bold . s:underline . s:italic)
call srcery#helper#Highlight('htmlUnderline', s:bright_white, s:black, s:underline)
call srcery#helper#Highlight('htmlUnderlineItalic', s:bright_white, s:black, s:underline . s:italic)
call srcery#helper#Highlight('htmlItalic', s:bright_white, s:black, s:italic)
endif
call srcery#helper#Highlight('htmlBold', s:bright_white, g:srcery_bg, s:bold)
call srcery#helper#Highlight('htmlBoldUnderline', s:bright_white, g:srcery_bg, s:bold . s:underline)
call srcery#helper#Highlight('htmlBoldItalic', s:bright_white, g:srcery_bg, s:bold . s:italic)
call srcery#helper#Highlight('htmlBoldUnderlineItalic', s:bright_white, g:srcery_bg, s:bold . s:underline . s:italic)
call srcery#helper#Highlight('htmlUnderline', s:bright_white, g:srcery_bg, s:underline)
call srcery#helper#Highlight('htmlUnderlineItalic', s:bright_white, g:srcery_bg, s:underline . s:italic)
call srcery#helper#Highlight('htmlItalic', s:bright_white, g:srcery_bg, s:italic)

" }}}
16 changes: 12 additions & 4 deletions autoload/srcery.vim
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ if !exists('g:srcery_italic')
endif
endif

if !exists('g:srcery_bg_passthrough')
let g:srcery_bg_passthrough=0
endif

if !exists('g:srcery_undercurl')
let g:srcery_undercurl=1
endif
Expand Down Expand Up @@ -152,6 +148,18 @@ if !exists('g:srcery_italic_types')
let g:srcery_italic_types=0
endif

if !exists('g:srcery_bg')
"Sets the default color for both guisp and cterm backgrounds.
let g:srcery_bg=[g:srcery_black, 0]
elseif (index(g:srcery_bg, 'DEFAULT') >= 0) || (index(g:srcery_bg, 'NONE') >= 0 && has('gui_running'))
"Defaults should be set if the user specifies it, or if the background is set as 'NONE' whilst the gui is running.
for i in [0, 1]
if g:srcery_bg[i] ==# 'DEFAULT' || (g:srcery_bg[i] ==# 'NONE' && has('gui_running'))
let g:srcery_bg[i] = (i==1 ? 0 : g:srcery_black)
endif
endfor
endif

if !exists('g:srcery_hard_black_terminal_bg')
let g:srcery_hard_black_terminal_bg=1
endif
Expand Down
85 changes: 23 additions & 62 deletions colors/srcery.vim
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ call s:HL('SrceryXgray6', s:xgray6)

" Normal text
"
if g:srcery_bg_passthrough == 1 && !has('gui_running')
call s:HL('Normal', s:bright_white, s:none)
else
call s:HL('Normal', s:bright_white, s:black)
endif
call s:HL('Normal', s:bright_white, g:srcery_bg)

if v:version >= 700
" Screen line that the cursor is
Expand Down Expand Up @@ -206,11 +202,7 @@ if v:version >= 703
call s:HL('Conceal', s:blue, s:none)

" Line number of CursorLine
if g:srcery_bg_passthrough == 1 && !has('gui_running')
call s:HL('CursorLineNr', s:yellow, s:none)
else
call s:HL('CursorLineNr', s:yellow, s:black)
endif
call s:HL('CursorLineNr', s:yellow, g:srcery_bg)

endif

Expand All @@ -237,19 +229,11 @@ call s:HL('Underlined', s:blue, s:none, s:underline)

call s:HL('StatusLine', s:bright_white, s:xgray2)

if g:srcery_bg_passthrough == 1 && !has('gui_running')
call s:HL('StatusLineNC', s:bright_black, s:none, s:underline)

" The column separating vertically split windows
call s:HL('VertSplit', s:bright_white, s:none)

" Current match in wildmenu completion
call s:HL('WildMenu', s:blue, s:none, s:bold)
else
call s:HL('StatusLineNC', s:bright_black, s:black, s:underline)
call s:HL('VertSplit', s:bright_white, s:black)
call s:HL('WildMenu', s:blue, s:black, s:bold)
endif
call s:HL('StatusLineNC', s:bright_black, g:srcery_bg, s:underline)
" The column separating vertically split windows
call s:HL('VertSplit', s:bright_white, g:srcery_bg)
" Current match in wildmenu completion
call s:HL('WildMenu', s:blue, g:srcery_bg, s:bold)

" Directory names, special names in listing
hi! link Directory SrceryGreenBold
Expand All @@ -274,19 +258,13 @@ hi! link WarningMsg SrceryRedBold
" Line number for :number and :# commands
call s:HL('LineNr', s:bright_black)

if g:srcery_bg_passthrough == 1 && !has('gui_running')
" Column where signs are displayed
" TODO Possibly need to fix SignColumn
call s:HL('SignColumn', s:none, s:none)
" Line used for closed folds
call s:HL('Folded', s:bright_black, s:none, s:italic)
" Column where folds are displayed
call s:HL('FoldColumn', s:bright_black, s:none)
else
call s:HL('SignColumn', s:none, s:black)
call s:HL('Folded', s:bright_black, s:black, s:italic)
call s:HL('FoldColumn', s:bright_black, s:black)
endif
" Column where signs are displayed
" TODO Possibly need to fix SignColumn
call s:HL('SignColumn', s:none, g:srcery_bg)
" Line used for closed folds
call s:HL('Folded', s:bright_black, g:srcery_bg, s:italic)
" Column where folds are displayed
call s:HL('FoldColumn', s:bright_black, g:srcery_bg)

" }}}
" Cursor: {{{
Expand All @@ -307,11 +285,7 @@ hi! link Special SrceryOrange

call s:HL('Comment', s:bright_black, s:none, s:italic)

if g:srcery_bg_passthrough == 1 && !has('gui_running')
call s:HL('Todo', s:bright_white, s:none, s:bold . s:italic)
else
call s:HL('Todo', s:bright_white, s:black, s:bold . s:italic)
endif
call s:HL('Todo', s:bright_white, g:srcery_bg, s:bold . s:italic)

call s:HL('Error', s:bright_white, s:red, s:bold)

Expand Down Expand Up @@ -388,31 +362,19 @@ if v:version >= 700
" Popup menu: selected item
call s:HL('PmenuSel', s:bright_white, s:blue, s:bold)

if g:srcery_bg_passthrough == 1 && !has('gui_running')
" Popup menu: scrollbar
call s:HL('PmenuSbar', s:none, s:none)
" Popup menu: scrollbar thumb
call s:HL('PmenuThumb', s:none, s:none)
else
call s:HL('PmenuSbar', s:none, s:black)
call s:HL('PmenuThumb', s:none, s:orange)
endif
" Popup menu: scrollbar
call s:HL('PmenuSbar', s:none, g:srcery_bg)
" Popup menu: scrollbar thumb
call s:HL('PmenuThumb', s:none, s:orange)
endif

" }}}
" Diffs: {{{

if g:srcery_bg_passthrough == 1 && !has('gui_running')
call s:HL('DiffDelete', s:red, s:none)
call s:HL('DiffAdd', s:green, s:none)
call s:HL('DiffChange', s:cyan, s:none)
call s:HL('DiffText', s:yellow, s:none)
else
call s:HL('DiffDelete', s:red, s:black)
call s:HL('DiffAdd', s:green, s:black)
call s:HL('DiffChange', s:cyan, s:black)
call s:HL('DiffText', s:yellow, s:black)
endif
call s:HL('DiffDelete', s:red, g:srcery_bg)
call s:HL('DiffAdd', s:green, g:srcery_bg)
call s:HL('DiffChange', s:cyan, g:srcery_bg)
call s:HL('DiffText', s:yellow, g:srcery_bg)

" }}}
" Spelling: {{{
Expand All @@ -436,7 +398,6 @@ if g:srcery_hard_black_terminal_bg == 1 && has('terminal')
" Therefore not useful with transparent background option
call s:HL('Terminal', s:bright_white, s:hard_black)
endif

" }}}
" Neovim LSP: {{{

Expand Down
8 changes: 8 additions & 0 deletions doc/srcery.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Options |srcery-options|
g:srcery_bg_passthrough |srcery-option-bg-passthrough|
g:srcery_guisp_fallback |srcery-option-guisp-fallback|
g:srcery_italic_types |srcery-option-italic-types|
g:srcery_bg |srcery-option-bg|
g:srcery_hard_black_terminal_bg |srcery-option-hard-black-terminal-bg|

==============================================================================
Expand Down Expand Up @@ -242,6 +243,13 @@ g:srcery_italic_types

Default: 0

*srcery-bg*
g:srcery_bg
Background color, specified as an RGB value.
Note that this will only work with `set termguicolors` in your config, and that it is mutually exclusive with `g:srcery_hard_black_terminal_bg`.

Default: `g:srcery_black`

*srcery-option-hard-black-terminal-bg*
g:srcery_hard_black_terminal_bg

Expand Down

0 comments on commit 7fecf70

Please sign in to comment.