1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 02:05:40 +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,7 +199,8 @@ 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],
@ -212,6 +213,7 @@ Add custom color palette for statusline and tabline.
\ ]
<
*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'