1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-12 17:55:41 +08:00

Add colors test

This commit is contained in:
wsdjeg 2017-10-23 23:14:13 +08:00
parent 2c5e2de843
commit 9fe68c4b40
3 changed files with 28 additions and 9 deletions

View File

@ -54,8 +54,20 @@ let s:self._color_map = {
\ '250': '#bcbcbc', '251': '#c6c6c6', '252': '#d0d0d0', '253': '#dadada', '254': '#e4e4e4',
\ '255': '#eeeeee', 'fg': 'fg', 'bg': 'bg', 'NONE': 'NONE' }
let s:self._deps = SpaceVim#api#import('data#dict')
function! s:self.nr2str(nr) abort
return get(self._color_map, a:nr, '')
endfunction
function! s:self.str2nr(str) abort
let nr = get(self._deps.swap(self._color_map), a:str, -1)
if nr =~ 'fg\|bg\|NONE'
return nr
else
return str2nr(nr)
endif
endfunction
function! SpaceVim#api#color#get() abort

View File

@ -199,19 +199,21 @@ statusline. To enable this feature:
<
*g:spacevim_custom_color_palette*
Add custom color palette for statusline and tabline.
Set the statusline/tabline palette of color, default values depends on the
theme
>
let g:spacevim_custom_color_palette = [
\ ['#282828', '#b8bb26', 246, 235],
\ ['#a89984', '#504945', 239, 246],
\ ['#a89984', '#3c3836', 237, 246],
\ ['#665c54', 241],
\ ['#282828', '#83a598', 235, 109],
\ ['#282828', '#fe8019', 235, 208],
\ ['#282828', '#8ec07c', 235, 108],
\ ]
\ ['#282828', '#b8bb26', 246, 235],
\ ['#a89984', '#504945', 239, 246],
\ ['#a89984', '#3c3836', 237, 246],
\ ['#665c54', 241],
\ ['#282828', '#83a598', 235, 109],
\ ['#282828', '#fe8019', 235, 208],
\ ['#282828', '#8ec07c', 235, 108],
\ ]
<
*g:spacevim_enable_cursorcolumn*
Enable/Disable cursorcolumn. Default is 0, cursorcolumn will be highlighted in
normal mode. To enable this feature:

5
test/api/color.vader Normal file
View File

@ -0,0 +1,5 @@
Execute ( SpaceVim api color ):
let color = SpaceVim#api#import('color')
AssertEqual color.nr2str(233), '#121212'
AssertEqual color.str2nr('#121212'), 233
AssertEqual color.str2nr('bg'), 'bg'