From a51dea0bc4d5cd5fae5ecfd6f526f03a083046d0 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 22 Aug 2013 12:05:53 +0900 Subject: [PATCH] Add colortable utility --- autoload/lightline/colortable.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 autoload/lightline/colortable.vim diff --git a/autoload/lightline/colortable.vim b/autoload/lightline/colortable.vim new file mode 100644 index 0000000..c3b9e8c --- /dev/null +++ b/autoload/lightline/colortable.vim @@ -0,0 +1,17 @@ +function! s:load() + let rgbfile = $VIMRUNTIME . '/rgb.txt' + let table = {} + if filereadable(rgbfile) + for _ in map(filter(readfile(rgbfile), 'v:val !~ "^!"'), 'matchlist(v:val, "^\\s*\\(\\d\\+\\)\\s\\+\\(\\d\\+\\)\\s\\+\\(\\d\\+\\)\\s\\+\\(.*\\)")[1:4]') + let table[tolower(_[3])] = _[0:2] + endfor + endif + return table +endfunction + +let s:table = s:load() + +function! lightline#colortable#name_to_rgb(name) + let name = tolower(a:name) + return has_key(s:table, name) ? s:table[name] : [] +endfunction