From cd18ffb1fb2f796fd769c7c00d775500f4fdac31 Mon Sep 17 00:00:00 2001 From: Derek Sifford Date: Sat, 25 May 2019 17:50:22 -0400 Subject: [PATCH] autoload color palette. closes #138 (#139) --- after/plugin/dracula.vim | 31 ++++---- after/syntax/javascript.vim | 2 +- after/syntax/markdown.vim | 2 +- autoload/airline/themes/dracula.vim | 14 ++-- autoload/dracula.vim | 47 +++++++++++ autoload/lightline/colorscheme/dracula.vim | 22 ++--- colors/dracula.vim | 93 ++++++---------------- 7 files changed, 106 insertions(+), 105 deletions(-) diff --git a/after/plugin/dracula.vim b/after/plugin/dracula.vim index c1a2b51..811cf96 100644 --- a/after/plugin/dracula.vim +++ b/after/plugin/dracula.vim @@ -5,19 +5,20 @@ endif " Fzf: {{{ if exists('g:loaded_fzf') && ! exists('g:fzf_colors') let g:fzf_colors = { - \ 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Search'], - \ 'fg+': ['fg', 'Normal'], - \ 'bg+': ['bg', 'Normal'], - \ 'hl+': ['fg', 'DraculaOrange'], - \ 'info': ['fg', 'DraculaPurple'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'DraculaGreen'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } + \ 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Search'], + \ 'fg+': ['fg', 'Normal'], + \ 'bg+': ['bg', 'Normal'], + \ 'hl+': ['fg', 'DraculaOrange'], + \ 'info': ['fg', 'DraculaPurple'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'DraculaGreen'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'], + \} endif "}}} " ALE: {{{ @@ -36,9 +37,9 @@ endif " }}} " CtrlP: {{{ if exists('g:loaded_ctrlp') - hi! link CtrlPMatch IncSearch + hi! link CtrlPMatch IncSearch hi! link CtrlPBufferHid Normal endif " }}} -" vim: fdm=marker ts=2 sts=2 sw=2: +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/after/syntax/javascript.vim b/after/syntax/javascript.vim index db20dfe..32e3390 100644 --- a/after/syntax/javascript.vim +++ b/after/syntax/javascript.vim @@ -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: diff --git a/after/syntax/markdown.vim b/after/syntax/markdown.vim index ff35ea4..0283a86 100644 --- a/after/syntax/markdown.vim +++ b/after/syntax/markdown.vim @@ -47,4 +47,4 @@ elseif b:current_syntax ==# 'markdown' "}}} endif -" vim: fdm=marker ts=2 sts=2 sw=2: +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/autoload/airline/themes/dracula.vim b/autoload/airline/themes/dracula.vim index 4c6d8f9..d0d90b1 100644 --- a/autoload/airline/themes/dracula.vim +++ b/autoload/airline/themes/dracula.vim @@ -14,14 +14,10 @@ " more attr-list items as input, transforms it to the format accepted by " airline#themes#generate_color_map and returns that value func! s:clr(fg, bg, ...) - let l:fg = get(g:dracula_palette, a:fg) - let l:bg = get(g:dracula_palette, a:bg) - if ! type(l:fg) == 3 - echoerr 'Color undefined in dracula_palette: ' . a:fg - 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') + let l:fg = g:dracula#palette[a:fg] + let l:bg = g:dracula#palette[a:bg] + return [ l:fg[0], l:bg[0], l:fg[1], l:bg[1] ] + + \ filter(copy(a:000), {_, val -> type(val) == 1 && len(val) > 0 }) endfunc " Takes three ['fg', 'bg'] color lists and optionally a dictionary of extra @@ -161,4 +157,4 @@ endif "}}}2 "}}} -" vim: fdm=marker ts=2 sts=2 sw=2: +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/autoload/dracula.vim b/autoload/dracula.vim index faad6fc..23f9656 100644 --- a/autoload/dracula.vim +++ b/autoload/dracula.vim @@ -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 " whether or not the execution of the ftplugin should be aborted. func! dracula#should_abort(...) @@ -8,3 +53,5 @@ func! dracula#should_abort(...) endif return 0 endfunction + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/autoload/lightline/colorscheme/dracula.vim b/autoload/lightline/colorscheme/dracula.vim index 71a0f1a..2cd283b 100644 --- a/autoload/lightline/colorscheme/dracula.vim +++ b/autoload/lightline/colorscheme/dracula.vim @@ -5,16 +5,16 @@ " Last Change: 2018/04/11 " ============================================================================= -let s:black = g:dracula_palette.bg -let s:gray = g:dracula_palette.selection -let s:white = g:dracula_palette.fg -let s:darkblue = g:dracula_palette.comment -let s:cyan = g:dracula_palette.cyan -let s:green = g:dracula_palette.green -let s:orange = g:dracula_palette.orange -let s:purple = g:dracula_palette.purple -let s:red = g:dracula_palette.red -let s:yellow = g:dracula_palette.yellow +let s:black = g:dracula#palette.bg +let s:gray = g:dracula#palette.selection +let s:white = g:dracula#palette.fg +let s:darkblue = g:dracula#palette.comment +let s:cyan = g:dracula#palette.cyan +let s:green = g:dracula#palette.green +let s:orange = g:dracula#palette.orange +let s:purple = g:dracula#palette.purple +let s:red = g:dracula#palette.red +let s:yellow = g:dracula#palette.yellow if exists('g:lightline') @@ -39,4 +39,4 @@ if exists('g:lightline') endif -" vim: fdm=marker ts=2 sts=2 sw=2: +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/colors/dracula.vim b/colors/dracula.vim index 4e29309..adf4245 100644 --- a/colors/dracula.vim +++ b/colors/dracula.vim @@ -31,74 +31,39 @@ endif " Palette: {{{2 -let s:fg = ['#F8F8F2', 253] +let s:fg = g:dracula#palette.fg -let s:bglighter = ['#424450', 238] -let s:bglight = ['#343746', 237] -let s:bg = ['#282A36', 236] -let s:bgdark = ['#21222C', 235] -let s:bgdarker = ['#191A21', 234] +let s:bglighter = g:dracula#palette.bglighter +let s:bglight = g:dracula#palette.bglight +let s:bg = g:dracula#palette.bg +let s:bgdark = g:dracula#palette.bgdark +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:comment = ['#6272A4', 61] -let s:cyan = ['#8BE9FD', 117] -let s:green = ['#50FA7B', 84] -let s:orange = ['#FFB86C', 215] -let s:pink = ['#FF79C6', 212] -let s:purple = ['#BD93F9', 141] -let s:red = ['#FF5555', 203] -let s:yellow = ['#F1FA8C', 228] +let s:cyan = g:dracula#palette.cyan +let s:green = g:dracula#palette.green +let s:orange = g:dracula#palette.orange +let s:pink = g:dracula#palette.pink +let s:purple = g:dracula#palette.purple +let s:red = g:dracula#palette.red +let s:yellow = g:dracula#palette.yellow 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') - let g:terminal_color_0 = '#21222C' - let g:terminal_color_1 = '#FF5555' - let g:terminal_color_2 = '#50FA7B' - 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' + for s:i in range(16) + let g:terminal_color_{s:i} = g:dracula#palette['color_' . s:i] + endfor endif if has('terminal') - let g:terminal_ansi_colors = [ - \ '#21222C', '#FF5555', '#50FA7B', '#F1FA8C', - \ '#BD93F9', '#FF79C6', '#8BE9FD', '#F8F8F2', - \ '#6272A4', '#FF6E6E', '#69FF94', '#FFFFA5', - \ '#D6ACFF', '#FF92DF', '#A4FFFF', '#FFFFFF' - \] + let g:terminal_ansi_colors = [] + for s:i in range(16) + call add(g:terminal_ansi_colors, g:dracula#palette['color_' . s:i]) + endfor endif " }}}2 @@ -165,14 +130,6 @@ function! s:h(scope, fg, ...) " bg, attr_list, special execute join(l:hl_string, ' ') endfunction -function! s:Background() - if g:dracula_colorterm || has('gui_running') - return s:bg - else - return s:none - endif -endfunction - "}}}2 " Dracula Highlight Groups: {{{2 @@ -242,7 +199,7 @@ call s:h('DraculaDiffDelete', s:red, s:bgdark) set background=dark " 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('StatusLineNC', s:none, s:bglight) 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: