add jellybeans theme using new highlight group methods

This commit is contained in:
Bailey Ling 2013-08-04 01:25:35 +00:00
parent 9f04ef3170
commit e4d5f4cfb1
4 changed files with 65 additions and 6 deletions

View File

@ -7,9 +7,9 @@ Lean & mean statusline for vim that's light as air.
# Features
* tiny core (under 200 lines), written with extensibility in mind (specifically adhering to the [open/closed principle][h]).
* integrates with a variety of plugins: [vim-bufferline][f], [fugitive][d], [unite][i], [ctrlp][j], [minibufexpl][o], [gundo][p], [undotree][q], [nerdtree][r], [tagbar][s], [syntastic][e] and [lawrencium][u].
* integrates with a variety of plugins, including: [vim-bufferline][f], [fugitive][d], [unite][i], [ctrlp][j], [minibufexpl][o], [gundo][p], [undotree][q], [nerdtree][r], [tagbar][s], [syntastic][e] and [lawrencium][u].
* looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols.
* optimized for speed; it loads in 1ms.
* optimized for speed; it loads in under a millisecond.
* fully customizable; if you know a little `statusline` syntax you can tweak it to your needs.
* trivial to write colorschemes; for a minimal theme you need to edit 9 lines of colors (please send pull requests).
* supports 7.2 as the minimum Vim version
@ -77,7 +77,7 @@ Contributions and pull requests are welcome. Please take note of the following
* adhere to the existing style as much as possible; notably, 2 space indents and long-form keywords.
* keep the history clean! squash your branches before you submit a pull request. `pull --rebase` is your friend.
* this plugin got a lot more popular than i initially expected, if you make changes to the core, please test on as many versions of vim as possible.
* any changes to the core should be tested against Vim 7.2.
* if you submit a theme, please create a screenshot so it can be added to the [Wiki][n].
# License

View File

@ -13,3 +13,25 @@ function! airline#themes#generate_color_map(section1, section2, section3, file)
\ 'file': [ a:file[0] , a:file[1] , a:file[2] , a:file[3] , get(a:file , 4, '' ) ] ,
\ }
endfunction
function! s:get_syn(group, what)
return synIDattr(synIDtrans(hlID(a:group)), a:what)
endfunction
function! s:get_array(fg, bg, opts)
return has('gui_running')
\ ? [ a:fg, a:bg, '', '', join(a:opts, ',') ]
\ : [ '', '', a:fg >= 0 ? a:fg : '', a:bg >= 0 ? a:bg : '', join(a:opts, ',') ]
endfunction
function! airline#themes#get_highlight(group, ...)
let fg = s:get_syn(a:group, 'fg')
let bg = s:get_syn(a:group, 'bg')
return s:get_array(fg, bg, a:000)
endfunction
function! airline#themes#get_highlight2(fg, bg, ...)
let fg = s:get_syn(a:fg[0], a:fg[1])
let bg = s:get_syn(a:bg[0], a:bg[1])
return s:get_array(fg, bg, a:000)
endfunction

View File

@ -0,0 +1,33 @@
" This theme is an example of how to use helper functions to extract highlight
" values from the corresponding colorscheme. It was written in a hurry, so it
" is very minimalistic. If you are a jellybeans user and want to make updates,
" please send pull requests.
" Here are examples where the entire highlight group is copied and an airline
" compatible color array is generated.
let s:file = airline#themes#get_highlight('Constant')
let s:N1 = airline#themes#get_highlight('DbgCurrent', 'bold')
let s:N2 = airline#themes#get_highlight('Folded')
let s:N3 = airline#themes#get_highlight('NonText')
let g:airline#themes#jellybeans#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file)
let s:I1 = airline#themes#get_highlight('DiffAdd', 'bold')
let s:I2 = s:N2
let s:I3 = s:N3
let g:airline#themes#jellybeans#insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3, s:file)
let s:R1 = airline#themes#get_highlight('WildMenu', 'bold')
let s:R2 = s:N2
let s:R3 = s:N3
let g:airline#themes#jellybeans#replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3, s:file)
" Sometimes you want to mix and match colors from different groups, you can do
" that with this method.
let s:V1 = airline#themes#get_highlight2(['TabLineSel', 'bg'], ['DiffDelete', 'bg'], 'bold')
let s:V2 = s:N2
let s:V3 = s:N3
let g:airline#themes#jellybeans#visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3, s:file)
" And of course, you can always do it manually as well.
let s:IA = [ '#444444', '#1c1c1c', 237, 234 ]
let g:airline#themes#jellybeans#inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file)

View File

@ -205,9 +205,13 @@ statusline modified. Here is an example:
WRITING THEMES *airline-themes*
Themes are written "close to the metal" -- you will need to know some basic
VimL syntax to write a theme, but if you're written in any programming
language it will be easy to pick up. Have a look at the dark.vim theme
where it is fully documented.
VimL syntax to write a theme, but if you've written in any programming
language before it will be easy to pick up.
The |dark.vim| theme fully documents this procedure and will guide you through
the process. The |jellybeans.vim| theme is another example of how to write a
theme, but instead of manually declaring colors, it extracts the values from
highlight groups.
==============================================================================
TROUBLESHOOTING *airline-troubleshooting*