From dc8073cd13d149be0578a5b5e36eaedef0a9ad5a Mon Sep 17 00:00:00 2001 From: Derek Sifford Date: Fri, 13 Apr 2018 20:50:26 -0400 Subject: [PATCH] Merge lightline + adjust lightline & airline (#72) * add built-in lightline support Co-authored-by: adamalbrecht * finish lightline merge * finish airline update * add inline doc comments to airline script functions * add back modified groups to airline * adjust maintainers + add @benknoble in README.md --- README.md | 7 +- autoload/airline/themes/dracula.vim | 193 +++++++++++---------- autoload/lightline/colorscheme/Dracula.vim | 42 +++++ colors/dracula.vim | 20 +++ 4 files changed, 172 insertions(+), 90 deletions(-) create mode 100644 autoload/lightline/colorscheme/Dracula.vim diff --git a/README.md b/README.md index 1e9420f..9f56313 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,13 @@ ## Install -All instructions can be found at [draculatheme.com/vim](https://draculatheme.com/vim). - +All instructions can be found at +[draculatheme.com/vim](https://draculatheme.com/vim). ## Team -This theme is maintained by the following person(s) and a bunch of [awesome contributors](https://github.com/dracula/vim/graphs/contributors). +This theme is maintained by the following person(s) and a bunch of +[awesome contributors](https://github.com/dracula/vim/graphs/contributors). [![Derek S.](https://avatars3.githubusercontent.com/u/5240018?v=3&s=70)](https://github.com/dsifford) | [![David Knoble](https://avatars0.githubusercontent.com/u/22802209?v=4&s=70)](https://github.com/benknoble) --- | --- diff --git a/autoload/airline/themes/dracula.vim b/autoload/airline/themes/dracula.vim index 89f7349..2a7a761 100644 --- a/autoload/airline/themes/dracula.vim +++ b/autoload/airline/themes/dracula.vim @@ -1,4 +1,4 @@ -" Dracula vim-airline theme +" Dracula Airline Theme: {{{ " " Copyright 2016, All rights reserved " @@ -7,96 +7,115 @@ " " @author Extrante " @author Zeno Rocha +"}}} +" Helpers: {{{ -" Color palette -let s:gui01 = "#44475a" -let s:gui02 = "#5f6a8e" -let s:gui03 = "#ffb86c" -let s:gui04 = "#bd93f9" -let s:gui05 = "#ff5555" -let s:gui06 = "#f1fa8c" -let s:gui07 = "#50fa7b" -let s:gui08 = "#bd93f9" -let s:cterm01 = "236" -let s:cterm02 = "61" -let s:cterm03 = "215" -let s:cterm04 = "141" -let s:cterm05 = "160" -let s:cterm06 = "228" -let s:cterm07 = "84" -let s:cterm08 = "141" +" Takes a foreground color name, background color name, and optionally one or +" 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') +endfunc -let s:guiWhite = "#f8f8f2" -let s:guiBlack = "#282a36" -let s:ctermWhite = "15" -let s:ctermBlack = "16" +" Takes three ['fg', 'bg'] color lists and optionally a dictionary of extra +" key-value pairs and returns the value generated by +" airline#themes#generate_color_map after optionally merging the dictionary of +" extra key-value pairs. +" +" a:a -> airline_a, airline_x +" a:b -> airline_b, airline_y +" a:c -> airline_c, airline_z +func! s:color_map(a, b, c, ...) + if a:0 == 0 + return call('airline#themes#generate_color_map', [call('s:clr', a:a), call('s:clr', a:b), call('s:clr', a:c)]) + else + return call('extend', [ call('airline#themes#generate_color_map', [call('s:clr', a:a), call('s:clr', a:b), call('s:clr', a:c)]) ] + a:000) + endif +endfunc -let s:ctermChangedColor = "59" -let s:guiChangedColor = "#5f5f5f" +"}}} -" Normal mode -let s:N1 = [ s:guiBlack , s:gui08 , s:ctermBlack , s:cterm08 ] -let s:N2 = [ s:guiWhite , s:gui02 , s:ctermWhite , s:cterm02 ] -let s:N3 = [ s:guiWhite , s:gui01 , s:ctermWhite , s:cterm01 ] +let g:airline#themes#dracula#palette = { +\ 'normal': s:color_map( +\ ['bg', 'purple'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'normal_modified': s:color_map( +\ ['bg', 'purple'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ ), +\ 'insert': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'insert_modified': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ ), +\ 'replace': s:color_map( +\ ['bg', 'orange'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'replace_modified': s:color_map( +\ ['bg', 'orange'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ ), +\ 'visual': s:color_map( +\ ['bg', 'yellow'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'visual_modified': s:color_map( +\ ['bg', 'yellow'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ ), +\ 'inactive': s:color_map( +\ ['fg', 'selection'], +\ ['fg', 'selection'], +\ ['fg', 'selection'], +\ ), +\} -" Insert mode -let s:I1 = [ s:guiBlack , s:gui07 , s:ctermBlack , s:cterm07 ] -let s:I2 = [ s:guiWhite , s:gui02 , s:ctermWhite , s:cterm02 ] -let s:I3 = [ s:guiWhite , s:gui01 , s:ctermWhite , s:cterm01 ] - -" Visual mode -let s:V1 = [ s:guiBlack , s:gui06 , s:ctermBlack , s:cterm06 ] -let s:V2 = [ s:guiWhite , s:gui02 , s:ctermWhite , s:cterm02 ] -let s:V3 = [ s:guiWhite , s:gui01 , s:ctermWhite, s:cterm01 ] - -" Replace mode -let s:R1 = [ s:guiBlack , s:gui05 , s:ctermWhite, s:cterm05 ] -let s:R2 = [ s:guiWhite , s:gui02 , s:ctermWhite, s:cterm02 ] -let s:R3 = [ s:guiWhite , s:gui01 , s:ctermWhite, s:cterm01 ] - -" File changed -let s:changed = [ s:guiWhite , s:guiChangedColor , s:ctermWhite , s:ctermChangedColor ] - -let g:airline#themes#dracula#palette = {} -let g:airline#themes#dracula#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) -let g:airline#themes#dracula#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) -let g:airline#themes#dracula#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) -let g:airline#themes#dracula#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) -let g:airline#themes#dracula#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) - -" Inactive mode -let s:IN1 = [ s:gui04 , s:guiWhite , s:cterm04 , s:ctermWhite ] -let s:IN2 = [ s:gui04 , s:gui01 , s:cterm04 , s:cterm01 ] -let s:IA = [ s:IN1[1] , s:IN2[1] , s:IN1[3] , s:IN2[3] , '' ] -let g:airline#themes#dracula#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) - -" Warning info -let s:WARNING = [ s:guiBlack, s:gui03, s:ctermBlack, s:cterm03 ] -let s:ERROR = [ s:guiWhite, s:gui05, s:ctermWhite, s:cterm05 ] - -let g:airline#themes#dracula#palette.normal.airline_warning = s:WARNING -let g:airline#themes#dracula#palette.insert.airline_warning = s:WARNING -let g:airline#themes#dracula#palette.visual.airline_warning = s:WARNING -let g:airline#themes#dracula#palette.replace.airline_warning = s:WARNING - -let g:airline#themes#dracula#palette.normal.airline_error = s:ERROR -let g:airline#themes#dracula#palette.insert.airline_error = s:ERROR -let g:airline#themes#dracula#palette.visual.airline_error = s:ERROR -let g:airline#themes#dracula#palette.replace.airline_error = s:ERROR - -" File modified and not saved -let g:airline#themes#dracula#palette.normal_modified = airline#themes#generate_color_map(s:N1, s:N2, s:changed) -let g:airline#themes#dracula#palette.insert_modified = airline#themes#generate_color_map(s:I1, s:I2, s:changed) -let g:airline#themes#dracula#palette.replace_modified = airline#themes#generate_color_map(s:R1, s:R2, s:changed) -let g:airline#themes#dracula#palette.visual_modified = airline#themes#generate_color_map(s:V1, s:V2, s:changed) - -" CtrlP -if !get(g:, 'loaded_ctrlp', 0) - finish +" Extensions: {{{ +" CtrlP: {{{2 +if exists('g:loaded_ctrlp') + let g:airline#themes#dracula#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ s:clr('fg', 'selection'), + \ s:clr('fg', 'comment'), + \ s:clr('fg', 'purple'), + \) endif +"}}}2 +"}}} -let s:CP1 = [ s:guiWhite , s:gui01 , s:ctermWhite , s:cterm01 ] -let s:CP2 = [ s:guiWhite , s:gui02 , s:ctermWhite , s:cterm02 ] -let s:CP3 = [ s:guiWhite , s:gui08 , s:ctermWhite , s:cterm08 ] - -let g:airline#themes#dracula#palette.ctrlp = airline#extensions#ctrlp#generate_color_map(s:CP1, s:CP2, s:CP3) +" vim: fdm=marker ts=2 sts=2 sw=2: diff --git a/autoload/lightline/colorscheme/Dracula.vim b/autoload/lightline/colorscheme/Dracula.vim new file mode 100644 index 0000000..4dcbb37 --- /dev/null +++ b/autoload/lightline/colorscheme/Dracula.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/Dracula.vim +" Author: adamalbrecht +" License: MIT License +" 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 + +if exists('g:lightline') + + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + let s:p.normal.left = [ [ s:black, s:purple ], [ s:cyan, s:gray ] ] + let s:p.normal.right = [ [ s:black, s:purple ], [ s:white, s:darkblue ] ] + let s:p.inactive.right = [ [ s:black, s:gray ], [ s:white, s:black ] ] + let s:p.inactive.left = [ [ s:cyan, s:black ], [ s:white, s:black ] ] + let s:p.insert.left = [ [ s:black, s:green ], [ s:cyan, s:gray ] ] + let s:p.replace.left = [ [ s:black, s:red ], [ s:cyan, s:gray ] ] + let s:p.visual.left = [ [ s:black, s:orange ], [ s:cyan, s:gray ] ] + let s:p.normal.middle = [ [ s:white, s:gray ] ] + let s:p.inactive.middle = [ [ s:white, s:gray ] ] + let s:p.tabline.left = [ [ s:darkblue, s:gray ] ] + let s:p.tabline.tabsel = [ [ s:cyan, s:black ] ] + let s:p.tabline.middle = [ [ s:darkblue, s:gray ] ] + let s:p.tabline.right = copy(s:p.normal.right) + let s:p.normal.error = [ [ s:red, s:black ] ] + let s:p.normal.warning = [ [ s:yellow, s:black ] ] + + let g:lightline#colorscheme#Dracula#palette = lightline#colorscheme#flatten(s:p) + +endif + +" vim: fdm=marker ts=2 sts=2 sw=2: diff --git a/colors/dracula.vim b/colors/dracula.vim index db65554..85e582a 100644 --- a/colors/dracula.vim +++ b/colors/dracula.vim @@ -53,6 +53,26 @@ let s:yellow = ['#F1FA8C', 228] 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 = '#44475A' let g:terminal_color_1 = '#DE312B'