autoload color palette. closes #138 (#139)

This commit is contained in:
Derek Sifford 2019-05-25 17:50:22 -04:00 committed by GitHub
parent bfbc3cadbd
commit cd18ffb1fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 105 deletions

View file

@ -17,7 +17,8 @@ if exists('g:loaded_fzf') && ! exists('g:fzf_colors')
\ 'pointer': ['fg', 'Exception'], \ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'], \ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'], \ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] } \ 'header': ['fg', 'Comment'],
\}
endif endif
"}}} "}}}
" ALE: {{{ " ALE: {{{
@ -41,4 +42,4 @@ if exists('g:loaded_ctrlp')
endif endif
" }}} " }}}
" vim: fdm=marker ts=2 sts=2 sw=2: " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0:

View file

@ -22,4 +22,4 @@ hi! link jsTemplateBraces Special
"}}} "}}}
" vim: set fdm=marker fdl=0: " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0:

View file

@ -47,4 +47,4 @@ elseif b:current_syntax ==# 'markdown'
"}}} "}}}
endif endif
" vim: fdm=marker ts=2 sts=2 sw=2: " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0:

View file

@ -14,14 +14,10 @@
" more attr-list items as input, transforms it to the format accepted by " more attr-list items as input, transforms it to the format accepted by
" airline#themes#generate_color_map and returns that value " airline#themes#generate_color_map and returns that value
func! s:clr(fg, bg, ...) func! s:clr(fg, bg, ...)
let l:fg = get(g:dracula_palette, a:fg) let l:fg = g:dracula#palette[a:fg]
let l:bg = get(g:dracula_palette, a:bg) let l:bg = g:dracula#palette[a:bg]
if ! type(l:fg) == 3 return [ l:fg[0], l:bg[0], l:fg[1], l:bg[1] ] +
echoerr 'Color undefined in dracula_palette: ' . a:fg \ filter(copy(a:000), {_, val -> type(val) == 1 && len(val) > 0 })
elseif ! type(l:bg) == 3
echoerr 'Color undefined in dracula_palette: ' . a:fg
endif
return [ l:fg[0], l:bg[0], l:fg[1], l:bg[1] ] + filter(copy(a:000), 'type(v:val) == 1 && len(v:val) > 0')
endfunc endfunc
" Takes three ['fg', 'bg'] color lists and optionally a dictionary of extra " Takes three ['fg', 'bg'] color lists and optionally a dictionary of extra
@ -161,4 +157,4 @@ endif
"}}}2 "}}}2
"}}} "}}}
" vim: fdm=marker ts=2 sts=2 sw=2: " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0:

View file

@ -1,3 +1,48 @@
" Palette: {{{
let g:dracula#palette = {}
let g:dracula#palette.fg = ['#F8F8F2', 253]
let g:dracula#palette.bglighter = ['#424450', 238]
let g:dracula#palette.bglight = ['#343746', 237]
let g:dracula#palette.bg = ['#282A36', 236]
let g:dracula#palette.bgdark = ['#21222C', 235]
let g:dracula#palette.bgdarker = ['#191A21', 234]
let g:dracula#palette.comment = ['#6272A4', 61]
let g:dracula#palette.selection = ['#44475A', 239]
let g:dracula#palette.subtle = ['#424450', 238]
let g:dracula#palette.cyan = ['#8BE9FD', 117]
let g:dracula#palette.green = ['#50FA7B', 84]
let g:dracula#palette.orange = ['#FFB86C', 215]
let g:dracula#palette.pink = ['#FF79C6', 212]
let g:dracula#palette.purple = ['#BD93F9', 141]
let g:dracula#palette.red = ['#FF5555', 203]
let g:dracula#palette.yellow = ['#F1FA8C', 228]
"
" ANSI
"
let g:dracula#palette.color_0 = '#21222C'
let g:dracula#palette.color_1 = '#FF5555'
let g:dracula#palette.color_2 = '#50FA7B'
let g:dracula#palette.color_3 = '#F1FA8C'
let g:dracula#palette.color_4 = '#BD93F9'
let g:dracula#palette.color_5 = '#FF79C6'
let g:dracula#palette.color_6 = '#8BE9FD'
let g:dracula#palette.color_7 = '#F8F8F2'
let g:dracula#palette.color_8 = '#6272A4'
let g:dracula#palette.color_9 = '#FF6E6E'
let g:dracula#palette.color_10 = '#69FF94'
let g:dracula#palette.color_11 = '#FFFFA5'
let g:dracula#palette.color_12 = '#D6ACFF'
let g:dracula#palette.color_13 = '#FF92DF'
let g:dracula#palette.color_14 = '#A4FFFF'
let g:dracula#palette.color_15 = '#FFFFFF'
" }}}
" Helper function that takes a variadic list of filetypes as args and returns " Helper function that takes a variadic list of filetypes as args and returns
" whether or not the execution of the ftplugin should be aborted. " whether or not the execution of the ftplugin should be aborted.
func! dracula#should_abort(...) func! dracula#should_abort(...)
@ -8,3 +53,5 @@ func! dracula#should_abort(...)
endif endif
return 0 return 0
endfunction endfunction
" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0:

View file

@ -5,16 +5,16 @@
" Last Change: 2018/04/11 " Last Change: 2018/04/11
" ============================================================================= " =============================================================================
let s:black = g:dracula_palette.bg let s:black = g:dracula#palette.bg
let s:gray = g:dracula_palette.selection let s:gray = g:dracula#palette.selection
let s:white = g:dracula_palette.fg let s:white = g:dracula#palette.fg
let s:darkblue = g:dracula_palette.comment let s:darkblue = g:dracula#palette.comment
let s:cyan = g:dracula_palette.cyan let s:cyan = g:dracula#palette.cyan
let s:green = g:dracula_palette.green let s:green = g:dracula#palette.green
let s:orange = g:dracula_palette.orange let s:orange = g:dracula#palette.orange
let s:purple = g:dracula_palette.purple let s:purple = g:dracula#palette.purple
let s:red = g:dracula_palette.red let s:red = g:dracula#palette.red
let s:yellow = g:dracula_palette.yellow let s:yellow = g:dracula#palette.yellow
if exists('g:lightline') if exists('g:lightline')
@ -39,4 +39,4 @@ if exists('g:lightline')
endif endif
" vim: fdm=marker ts=2 sts=2 sw=2: " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0:

View file

@ -31,74 +31,39 @@ endif
" Palette: {{{2 " Palette: {{{2
let s:fg = ['#F8F8F2', 253] let s:fg = g:dracula#palette.fg
let s:bglighter = ['#424450', 238] let s:bglighter = g:dracula#palette.bglighter
let s:bglight = ['#343746', 237] let s:bglight = g:dracula#palette.bglight
let s:bg = ['#282A36', 236] let s:bg = g:dracula#palette.bg
let s:bgdark = ['#21222C', 235] let s:bgdark = g:dracula#palette.bgdark
let s:bgdarker = ['#191A21', 234] let s:bgdarker = g:dracula#palette.bgdarker
let s:subtle = ['#424450', 238] let s:comment = g:dracula#palette.comment
let s:selection = g:dracula#palette.selection
let s:subtle = g:dracula#palette.subtle
let s:selection = ['#44475A', 239] let s:cyan = g:dracula#palette.cyan
let s:comment = ['#6272A4', 61] let s:green = g:dracula#palette.green
let s:cyan = ['#8BE9FD', 117] let s:orange = g:dracula#palette.orange
let s:green = ['#50FA7B', 84] let s:pink = g:dracula#palette.pink
let s:orange = ['#FFB86C', 215] let s:purple = g:dracula#palette.purple
let s:pink = ['#FF79C6', 212] let s:red = g:dracula#palette.red
let s:purple = ['#BD93F9', 141] let s:yellow = g:dracula#palette.yellow
let s:red = ['#FF5555', 203]
let s:yellow = ['#F1FA8C', 228]
let s:none = ['NONE', 'NONE'] let s:none = ['NONE', 'NONE']
let g:dracula_palette = {
\ 'fg': s:fg,
\ 'bg': s:bg,
\ 'selection': s:selection,
\ 'comment': s:comment,
\ 'cyan': s:cyan,
\ 'green': s:green,
\ 'orange': s:orange,
\ 'pink': s:pink,
\ 'purple': s:purple,
\ 'red': s:red,
\ 'yellow': s:yellow,
\
\ 'bglighter': s:bglighter,
\ 'bglight': s:bglight,
\ 'bgdark': s:bgdark,
\ 'bgdarker': s:bgdarker,
\ 'subtle': s:subtle,
\}
if has('nvim') if has('nvim')
let g:terminal_color_0 = '#21222C' for s:i in range(16)
let g:terminal_color_1 = '#FF5555' let g:terminal_color_{s:i} = g:dracula#palette['color_' . s:i]
let g:terminal_color_2 = '#50FA7B' endfor
let g:terminal_color_3 = '#F1FA8C'
let g:terminal_color_4 = '#BD93F9'
let g:terminal_color_5 = '#FF79C6'
let g:terminal_color_6 = '#8BE9FD'
let g:terminal_color_7 = '#F8F8F2'
let g:terminal_color_8 = '#6272A4'
let g:terminal_color_9 = '#FF6E6E'
let g:terminal_color_10 = '#69FF94'
let g:terminal_color_11 = '#FFFFA5'
let g:terminal_color_12 = '#D6ACFF'
let g:terminal_color_13 = '#FF92DF'
let g:terminal_color_14 = '#A4FFFF'
let g:terminal_color_15 = '#FFFFFF'
endif endif
if has('terminal') if has('terminal')
let g:terminal_ansi_colors = [ let g:terminal_ansi_colors = []
\ '#21222C', '#FF5555', '#50FA7B', '#F1FA8C', for s:i in range(16)
\ '#BD93F9', '#FF79C6', '#8BE9FD', '#F8F8F2', call add(g:terminal_ansi_colors, g:dracula#palette['color_' . s:i])
\ '#6272A4', '#FF6E6E', '#69FF94', '#FFFFA5', endfor
\ '#D6ACFF', '#FF92DF', '#A4FFFF', '#FFFFFF'
\]
endif endif
" }}}2 " }}}2
@ -165,14 +130,6 @@ function! s:h(scope, fg, ...) " bg, attr_list, special
execute join(l:hl_string, ' ') execute join(l:hl_string, ' ')
endfunction endfunction
function! s:Background()
if g:dracula_colorterm || has('gui_running')
return s:bg
else
return s:none
endif
endfunction
"}}}2 "}}}2
" Dracula Highlight Groups: {{{2 " Dracula Highlight Groups: {{{2
@ -242,7 +199,7 @@ call s:h('DraculaDiffDelete', s:red, s:bgdark)
set background=dark set background=dark
" Required as some plugins will overwrite " Required as some plugins will overwrite
call s:h('Normal', s:fg, s:Background()) call s:h('Normal', s:fg, g:dracula_colorterm || has('gui_running') ? s:bg : s:none )
call s:h('StatusLine', s:none, s:bglighter, [s:attrs.bold]) call s:h('StatusLine', s:none, s:bglighter, [s:attrs.bold])
call s:h('StatusLineNC', s:none, s:bglight) call s:h('StatusLineNC', s:none, s:bglight)
call s:h('StatusLineTerm', s:none, s:bglighter, [s:attrs.bold]) call s:h('StatusLineTerm', s:none, s:bglighter, [s:attrs.bold])
@ -348,4 +305,4 @@ hi! link helpBacktick Special
"}}} "}}}
" vim: fdm=marker ts=2 sts=2 sw=2: " vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: