From ce553ec9c0ec22c4bd9525d99e0b483976219e4e Mon Sep 17 00:00:00 2001 From: TKNGUE Date: Sun, 26 Jul 2015 20:10:23 +0900 Subject: [PATCH 1/6] Add papercolor_light scheme for lightline.vim --- .../colorscheme/papercolor_light.vim | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 autoload/lightline/colorscheme/papercolor_light.vim diff --git a/autoload/lightline/colorscheme/papercolor_light.vim b/autoload/lightline/colorscheme/papercolor_light.vim new file mode 100644 index 0000000..66052ad --- /dev/null +++ b/autoload/lightline/colorscheme/papercolor_light.vim @@ -0,0 +1,259 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/autoload/lightline/colorscheme/papercolor_light.vim +" Author: TKNGUE +" License: MIT License +" Last Change: 2015/07/21 13:18:03 +" ============================================================================= + +fun! grey_number(x) "{{{ + if &t_Co == 88 + if a:x < 23 + return 0 + elseif a:x < 69 + return 1 + elseif a:x < 103 + return 2 + elseif a:x < 127 + return 3 + elseif a:x < 150 + return 4 + elseif a:x < 173 + return 5 + elseif a:x < 196 + return 6 + elseif a:x < 219 + return 7 + elseif a:x < 243 + return 8 + else + return 9 + endif + else + if a:x < 14 + return 0 + else + let l:n = (a:x - 8) / 10 + let l:m = (a:x - 8) % 10 + if l:m < 5 + return l:n + else + return l:n + 1 + endif + endif + endif + endfun"}}} + + " Returns the actual grey level represented by the grey index + fun! grey_level(n)"{{{ + if &t_Co == 88 + if a:n == 0 + return 0 + elseif a:n == 1 + return 46 + elseif a:n == 2 + return 92 + elseif a:n == 3 + return 115 + elseif a:n == 4 + return 139 + elseif a:n == 5 + return 162 + elseif a:n == 6 + return 185 + elseif a:n == 7 + return 208 + elseif a:n == 8 + return 231 + else + return 255 + endif + else + if a:n == 0 + return 0 + else + return 8 + (a:n * 10) + endif + endif + endfun"}}} + + " Returns the palette index for the given grey index + fun! grey_colour(n)"{{{ + if &t_Co == 88 + if a:n == 0 + return 16 + elseif a:n == 9 + return 79 + else + return 79 + a:n + endif + else + if a:n == 0 + return 16 + elseif a:n == 25 + return 231 + else + return 231 + a:n + endif + endif + endfun"}}} + + " Returns an approximate colour index for the given colour level + fun! rgb_number(x)"{{{ + if &t_Co == 88 + if a:x < 69 + return 0 + elseif a:x < 172 + return 1 + elseif a:x < 230 + return 2 + else + return 3 + endif + else + if a:x < 75 + return 0 + else + let l:n = (a:x - 55) / 40 + let l:m = (a:x - 55) % 40 + if l:m < 20 + return l:n + else + return l:n + 1 + endif + endif + endif + endfun"}}} + + " Returns the actual colour level for the given colour index + fun! rgb_level(n)"{{{ + if &t_Co == 88 + if a:n == 0 + return 0 + elseif a:n == 1 + return 139 + elseif a:n == 2 + return 205 + else + return 255 + endif + else + if a:n == 0 + return 0 + else + return 55 + (a:n * 40) + endif + endif + endfun"}}} + + " Returns the palette index for the given R/G/B colour indices + fun! rgb_colour(x, y, z)"{{{ + if &t_Co == 88 + return 16 + (a:x * 16) + (a:y * 4) + a:z + else + return 16 + (a:x * 36) + (a:y * 6) + a:z + endif + endfun"}}} + + " Returns the palette index to approximate the given R/G/B colour levels + fun! colour(r, g, b)"{{{ + " Get the closest grey + let l:gx = grey_number(a:r) + let l:gy = grey_number(a:g) + let l:gz = grey_number(a:b) + + " Get the closest colour + let l:x = rgb_number(a:r) + let l:y = rgb_number(a:g) + let l:z = rgb_number(a:b) + + if l:gx == l:gy && l:gy == l:gz + " There are two possibilities + let l:dgr = grey_level(l:gx) - a:r + let l:dgg = grey_level(l:gy) - a:g + let l:dgb = grey_level(l:gz) - a:b + let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) + let l:dr = rgb_level(l:gx) - a:r + let l:dg = rgb_level(l:gy) - a:g + let l:db = rgb_level(l:gz) - a:b + let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) + if l:dgrey < l:drgb + " Use the grey + return grey_colour(l:gx) + else + " Use the colour + return rgb_colour(l:x, l:y, l:z) + endif + else + " Only one possibility + return rgb_colour(l:x, l:y, l:z) + endif + endfun"}}} + + " Returns the palette index to approximate the '#rrggbb' hex string + fun! rgb(rgb)"{{{ + let l:r = ("0x" . strpart(a:rgb, 1, 2)) + 0 + let l:g = ("0x" . strpart(a:rgb, 3, 2)) + 0 + let l:b = ("0x" . strpart(a:rgb, 5, 2)) + 0 + + return colour(l:r, l:g, l:b) + endfun"}}} + + fun! X(color)"{{{ + return [a:color, rgb(a:color)] + endfun"}}} + +let s:red = X("#df0000") "Include/Exception +let s:green = X("#008700") "Boolean/Special +let s:blue = X("#4271ae") "Keyword + +let s:pink = X("#d7005f") "Type +let s:olive = X("#718c00") "String +let s:navy = X("#005f87") "StorageClass + +let s:orange = X("#d75f00") "Number +let s:purple = X("#8959a8") "Repeat/Conditional +let s:aqua = X("#3e999f") "Operator/Delimiter + + +" Basics: +let s:foreground = X("#4d4d4c") +let s:background = X("#F5F5F5") +let s:window = X("#efefef") +let s:status = s:aqua +let s:error = X("#ffafdf") + +" Tabline: +let s:tabline_bg = s:navy +let s:tabline_active_fg = s:foreground +let s:tabline_active_bg = s:window +let s:tabline_inactive_fg = s:background +let s:tabline_inactive_bg = s:aqua + +" Statusline: +let s:statusline_active_fg = s:window +let s:statusline_active_bg = s:navy +let s:statusline_inactive_fg = s:foreground +let s:statusline_inactive_bg = X("#dadada") + +" Visual: +let s:visual_fg = s:background +let s:visual_bg = s:blue + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] +let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.middle = [ [ s:foreground, s:background ], ] +" let s:p.insert.left = [ [ s:base0, s:base0 ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.visual.left = [ [ s:background, s:blue ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] +let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] +let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:background, s:error ] ] +let s:p.normal.warning = [ [ s:background, s:olive ] ] + +let lightline#colorscheme#papercolor_light#palette = lightline#colorscheme#flatten(s:p) From dab0cd7d026ff32d52529040e435102455dbeb57 Mon Sep 17 00:00:00 2001 From: TKNGUE Date: Sun, 26 Jul 2015 20:33:22 +0900 Subject: [PATCH 2/6] Add papercolor_dark scheme for lightline.vim --- .../lightline/colorscheme/papercolor_dark.vim | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 autoload/lightline/colorscheme/papercolor_dark.vim diff --git a/autoload/lightline/colorscheme/papercolor_dark.vim b/autoload/lightline/colorscheme/papercolor_dark.vim new file mode 100644 index 0000000..84202e4 --- /dev/null +++ b/autoload/lightline/colorscheme/papercolor_dark.vim @@ -0,0 +1,246 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/autoload/lightline/colorscheme/papercolor_light.vim +" Author: TKNGUE +" License: MIT License +" Last Change: 2015/07/21 13:18:03 +" ============================================================================= + +fun! grey_number(x) "{{{ + if &t_Co == 88 + if a:x < 23 + return 0 + elseif a:x < 69 + return 1 + elseif a:x < 103 + return 2 + elseif a:x < 127 + return 3 + elseif a:x < 150 + return 4 + elseif a:x < 173 + return 5 + elseif a:x < 196 + return 6 + elseif a:x < 219 + return 7 + elseif a:x < 243 + return 8 + else + return 9 + endif + else + if a:x < 14 + return 0 + else + let l:n = (a:x - 8) / 10 + let l:m = (a:x - 8) % 10 + if l:m < 5 + return l:n + else + return l:n + 1 + endif + endif + endif + endfun"}}} + + " Returns the actual grey level represented by the grey index + fun! grey_level(n)"{{{ + if &t_Co == 88 + if a:n == 0 + return 0 + elseif a:n == 1 + return 46 + elseif a:n == 2 + return 92 + elseif a:n == 3 + return 115 + elseif a:n == 4 + return 139 + elseif a:n == 5 + return 162 + elseif a:n == 6 + return 185 + elseif a:n == 7 + return 208 + elseif a:n == 8 + return 231 + else + return 255 + endif + else + if a:n == 0 + return 0 + else + return 8 + (a:n * 10) + endif + endif + endfun"}}} + + " Returns the palette index for the given grey index + fun! grey_colour(n)"{{{ + if &t_Co == 88 + if a:n == 0 + return 16 + elseif a:n == 9 + return 79 + else + return 79 + a:n + endif + else + if a:n == 0 + return 16 + elseif a:n == 25 + return 231 + else + return 231 + a:n + endif + endif + endfun"}}} + + " Returns an approximate colour index for the given colour level + fun! rgb_number(x)"{{{ + if &t_Co == 88 + if a:x < 69 + return 0 + elseif a:x < 172 + return 1 + elseif a:x < 230 + return 2 + else + return 3 + endif + else + if a:x < 75 + return 0 + else + let l:n = (a:x - 55) / 40 + let l:m = (a:x - 55) % 40 + if l:m < 20 + return l:n + else + return l:n + 1 + endif + endif + endif + endfun"}}} + + " Returns the actual colour level for the given colour index + fun! rgb_level(n)"{{{ + if &t_Co == 88 + if a:n == 0 + return 0 + elseif a:n == 1 + return 139 + elseif a:n == 2 + return 205 + else + return 255 + endif + else + if a:n == 0 + return 0 + else + return 55 + (a:n * 40) + endif + endif + endfun"}}} + + " Returns the palette index for the given R/G/B colour indices + fun! rgb_colour(x, y, z)"{{{ + if &t_Co == 88 + return 16 + (a:x * 16) + (a:y * 4) + a:z + else + return 16 + (a:x * 36) + (a:y * 6) + a:z + endif + endfun"}}} + + " Returns the palette index to approximate the given R/G/B colour levels + fun! colour(r, g, b)"{{{ + " Get the closest grey + let l:gx = grey_number(a:r) + let l:gy = grey_number(a:g) + let l:gz = grey_number(a:b) + + " Get the closest colour + let l:x = rgb_number(a:r) + let l:y = rgb_number(a:g) + let l:z = rgb_number(a:b) + + if l:gx == l:gy && l:gy == l:gz + " There are two possibilities + let l:dgr = grey_level(l:gx) - a:r + let l:dgg = grey_level(l:gy) - a:g + let l:dgb = grey_level(l:gz) - a:b + let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) + let l:dr = rgb_level(l:gx) - a:r + let l:dg = rgb_level(l:gy) - a:g + let l:db = rgb_level(l:gz) - a:b + let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) + if l:dgrey < l:drgb + " Use the grey + return grey_colour(l:gx) + else + " Use the colour + return rgb_colour(l:x, l:y, l:z) + endif + else + " Only one possibility + return rgb_colour(l:x, l:y, l:z) + endif + endfun"}}} + + " Returns the palette index to approximate the '#rrggbb' hex string + fun! rgb(rgb)"{{{ + let l:r = ("0x" . strpart(a:rgb, 1, 2)) + 0 + let l:g = ("0x" . strpart(a:rgb, 3, 2)) + 0 + let l:b = ("0x" . strpart(a:rgb, 5, 2)) + 0 + + return colour(l:r, l:g, l:b) + endfun"}}} + + fun! X(color)"{{{ + return [a:color, rgb(a:color)] + endfun"}}} + +" Basics: +let s:foreground = X("#d0d0d0") +let s:background = X("#444444") +let s:window = X("#efefef") +let s:status = s:aqua +let s:error = X("#5f0000") + +" Tabline: +let s:tabline_bg = X("#3a3a3a") +let s:tabline_active_fg = X("#1c1c1c") +let s:tabline_active_bg = X("#00afaf") +let s:tabline_inactive_fg = X("#c6c6c6") +let s:tabline_inactive_bg = X("#585858") + +" Statusline: +let s:statusline_active_fg = X("#1c1c1c") +let s:statusline_active_bg = X("#5f8787") +let s:statusline_inactive_fg = X("#c6c6c6") +let s:statusline_inactive_bg = X("#444444") + +" Visual: +let s:visual_fg = X("#000000") +let s:visual_bg = X("#8787af") + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] +let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.middle = [ [ s:foreground, s:background ], ] +let s:p.insert.left = [ [ s:blue, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.visual.left = [ [ s:visual_fg, s:visual_bg ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] +let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] +let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:background, s:error ] ] +let s:p.normal.warning = [ [ s:background, s:olive ] ] + +let lightline#colorscheme#papercolor_dark#palette = lightline#colorscheme#flatten(s:p) From f66b7345a15afeb371b292d6c67daa108de4759a Mon Sep 17 00:00:00 2001 From: TKNGUE Date: Sun, 26 Jul 2015 20:51:39 +0900 Subject: [PATCH 3/6] Update papercolor scheme --- autoload/lightline/colorscheme/papercolor.vim | 11 ++++++++++ .../lightline/colorscheme/papercolor_dark.vim | 19 ++++++++++++---- .../colorscheme/papercolor_light.vim | 22 +++++++++---------- 3 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 autoload/lightline/colorscheme/papercolor.vim diff --git a/autoload/lightline/colorscheme/papercolor.vim b/autoload/lightline/colorscheme/papercolor.vim new file mode 100644 index 0000000..b754e6c --- /dev/null +++ b/autoload/lightline/colorscheme/papercolor.vim @@ -0,0 +1,11 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/papercolor.vim +" Author: TKNGUE +" License: MIT License +" Last Change: 2015-07-26 20:34 +" ============================================================================= +if &background ==# 'light' + let g:lightline#colorscheme#papercolor#palette = g:lightline#colorscheme#papercolor_light#palette +else + let g:lightline#colorscheme#papercolor#palette = g:lightline#colorscheme#papercolor_dark#palette +endif diff --git a/autoload/lightline/colorscheme/papercolor_dark.vim b/autoload/lightline/colorscheme/papercolor_dark.vim index 84202e4..e53a0ce 100644 --- a/autoload/lightline/colorscheme/papercolor_dark.vim +++ b/autoload/lightline/colorscheme/papercolor_dark.vim @@ -202,11 +202,23 @@ fun! grey_number(x) "{{{ return [a:color, rgb(a:color)] endfun"}}} +let s:red = X("#df0000") +let s:green = X("#008700") +let s:blue = X("#00afaf") + +let s:pink = X("#afdf00") +let s:olive = X("#dfaf5f") +let s:navy = X("#df875f") + +let s:orange = X("#d75f00") +let s:purple = X("#8959a8") +let s:aqua = X("#3e999f") + " Basics: let s:foreground = X("#d0d0d0") let s:background = X("#444444") let s:window = X("#efefef") -let s:status = s:aqua +let s:status = X("#c6c6c6") let s:error = X("#5f0000") " Tabline: @@ -233,7 +245,7 @@ let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] let s:p.inactive.middle = [ [ s:foreground, s:background ], ] -let s:p.insert.left = [ [ s:blue, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.insert.left = [ [ s:background, s:blue], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] let s:p.visual.left = [ [ s:visual_fg, s:visual_bg ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] @@ -241,6 +253,5 @@ let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] let s:p.tabline.right = copy(s:p.normal.right) let s:p.normal.error = [ [ s:background, s:error ] ] -let s:p.normal.warning = [ [ s:background, s:olive ] ] -let lightline#colorscheme#papercolor_dark#palette = lightline#colorscheme#flatten(s:p) +let g:lightline#colorscheme#papercolor_dark#palette = lightline#colorscheme#flatten(s:p) diff --git a/autoload/lightline/colorscheme/papercolor_light.vim b/autoload/lightline/colorscheme/papercolor_light.vim index 66052ad..0e441ee 100644 --- a/autoload/lightline/colorscheme/papercolor_light.vim +++ b/autoload/lightline/colorscheme/papercolor_light.vim @@ -240,20 +240,20 @@ let s:visual_fg = s:background let s:visual_bg = s:blue let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] -let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] -let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] -let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] -let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] -let s:p.inactive.middle = [ [ s:foreground, s:background ], ] -" let s:p.insert.left = [ [ s:base0, s:base0 ], [ s:base3, s:base01 ] ] +let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] +let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.middle = [ [ s:foreground, s:background ], ] +let s:p.insert.left = [ [ s:blue, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] let s:p.visual.left = [ [ s:background, s:blue ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] -let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] -let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] -let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] +let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] +let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] +let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] let s:p.tabline.right = copy(s:p.normal.right) let s:p.normal.error = [ [ s:background, s:error ] ] let s:p.normal.warning = [ [ s:background, s:olive ] ] -let lightline#colorscheme#papercolor_light#palette = lightline#colorscheme#flatten(s:p) +let g:lightline#colorscheme#papercolor_light#palette = lightline#colorscheme#flatten(s:p) From 90f0409675926f9161904bece09adb1a2b42457d Mon Sep 17 00:00:00 2001 From: TKNGUE Date: Mon, 27 Jul 2015 05:54:31 +0900 Subject: [PATCH 4/6] Rename papercolor -> PaperColor For compatibility PaperColor colorscheme --- .../lightline/colorscheme/{papercolor.vim => PaperColor.vim} | 1 + .../colorscheme/{papercolor_dark.vim => PaperColor_dark.vim} | 0 .../colorscheme/{papercolor_light.vim => PaperColor_light.vim} | 0 3 files changed, 1 insertion(+) rename autoload/lightline/colorscheme/{papercolor.vim => PaperColor.vim} (99%) rename autoload/lightline/colorscheme/{papercolor_dark.vim => PaperColor_dark.vim} (100%) rename autoload/lightline/colorscheme/{papercolor_light.vim => PaperColor_light.vim} (100%) diff --git a/autoload/lightline/colorscheme/papercolor.vim b/autoload/lightline/colorscheme/PaperColor.vim similarity index 99% rename from autoload/lightline/colorscheme/papercolor.vim rename to autoload/lightline/colorscheme/PaperColor.vim index b754e6c..082ada0 100644 --- a/autoload/lightline/colorscheme/papercolor.vim +++ b/autoload/lightline/colorscheme/PaperColor.vim @@ -9,3 +9,4 @@ if &background ==# 'light' else let g:lightline#colorscheme#papercolor#palette = g:lightline#colorscheme#papercolor_dark#palette endif + diff --git a/autoload/lightline/colorscheme/papercolor_dark.vim b/autoload/lightline/colorscheme/PaperColor_dark.vim similarity index 100% rename from autoload/lightline/colorscheme/papercolor_dark.vim rename to autoload/lightline/colorscheme/PaperColor_dark.vim diff --git a/autoload/lightline/colorscheme/papercolor_light.vim b/autoload/lightline/colorscheme/PaperColor_light.vim similarity index 100% rename from autoload/lightline/colorscheme/papercolor_light.vim rename to autoload/lightline/colorscheme/PaperColor_light.vim From eff430dd850705d6bc8b7bf057a800c667d9c76c Mon Sep 17 00:00:00 2001 From: TKNGUE Date: Mon, 27 Jul 2015 06:01:35 +0900 Subject: [PATCH 5/6] Fix formats following author's request - Stop using abbreviations and . - Remove duplicated codes. - Fix Briticism English --- autoload/lightline/colorscheme/PaperColor.vim | 211 ++++++++++++++- .../lightline/colorscheme/PaperColor_dark.vim | 253 ++---------------- .../colorscheme/PaperColor_light.vim | 234 ++-------------- 3 files changed, 249 insertions(+), 449 deletions(-) diff --git a/autoload/lightline/colorscheme/PaperColor.vim b/autoload/lightline/colorscheme/PaperColor.vim index 082ada0..7c568d3 100644 --- a/autoload/lightline/colorscheme/PaperColor.vim +++ b/autoload/lightline/colorscheme/PaperColor.vim @@ -1,12 +1,209 @@ " ============================================================================= -" Filename: autoload/lightline/colorscheme/papercolor.vim +" Filename: autoload/lightline/colorscheme/PaperColor.vim " Author: TKNGUE " License: MIT License -" Last Change: 2015-07-26 20:34 +" Last Change: 2015-07-27 06:01 " ============================================================================= -if &background ==# 'light' - let g:lightline#colorscheme#papercolor#palette = g:lightline#colorscheme#papercolor_light#palette -else - let g:lightline#colorscheme#papercolor#palette = g:lightline#colorscheme#papercolor_dark#palette -endif + function! s:grey_number(x) + if &t_Co == 88 + if a:x < 23 + return 0 + elseif a:x < 69 + return 1 + elseif a:x < 103 + return 2 + elseif a:x < 127 + return 3 + elseif a:x < 150 + return 4 + elseif a:x < 173 + return 5 + elseif a:x < 196 + return 6 + elseif a:x < 219 + return 7 + elseif a:x < 243 + return 8 + else + return 9 + endif + else + if a:x < 14 + return 0 + else + let l:n = (a:x - 8) / 10 + let l:m = (a:x - 8) % 10 + if l:m < 5 + return l:n + else + return l:n + 1 + endif + endif + endif + endfunction + " Returns the actual grey level represented by the grey index + function! s:grey_level(n) + if &t_Co == 88 + if a:n == 0 + return 0 + elseif a:n == 1 + return 46 + elseif a:n == 2 + return 92 + elseif a:n == 3 + return 115 + elseif a:n == 4 + return 139 + elseif a:n == 5 + return 162 + elseif a:n == 6 + return 185 + elseif a:n == 7 + return 208 + elseif a:n == 8 + return 231 + else + return 255 + endif + else + if a:n == 0 + return 0 + else + return 8 + (a:n * 10) + endif + endif + endfunction + + " Returns the palette index for the given grey index + function! s:grey_color(n) + if &t_Co == 88 + if a:n == 0 + return 16 + elseif a:n == 9 + return 79 + else + return 79 + a:n + endif + else + if a:n == 0 + return 16 + elseif a:n == 25 + return 231 + else + return 231 + a:n + endif + endif + endfunction + + " Returns an approximate color index for the given color level + function! s:rgb_number(x) + if &t_Co == 88 + if a:x < 69 + return 0 + elseif a:x < 172 + return 1 + elseif a:x < 230 + return 2 + else + return 3 + endif + else + if a:x < 75 + return 0 + else + let l:n = (a:x - 55) / 40 + let l:m = (a:x - 55) % 40 + if l:m < 20 + return l:n + else + return l:n + 1 + endif + endif + endif + endfunction + + " Returns the actual color level for the given color index + function! s:rgb_level(n) + if &t_Co == 88 + if a:n == 0 + return 0 + elseif a:n == 1 + return 139 + elseif a:n == 2 + return 205 + else + return 255 + endif + else + if a:n == 0 + return 0 + else + return 55 + (a:n * 40) + endif + endif + endfunction + + " Returns the palette index for the given R/G/B color indices + function! s:rgb_color(x, y, z) + if &t_Co == 88 + return 16 + (a:x * 16) + (a:y * 4) + a:z + else + return 16 + (a:x * 36) + (a:y * 6) + a:z + endif + endfunction + + " Returns the palette index to approximate the given R/G/B color levels + function! s:color(r, g, b) + " Get the closest grey + let l:gx = s:grey_number(a:r) + let l:gy = s:grey_number(a:g) + let l:gz = s:grey_number(a:b) + + " Get the closest color + let l:x = s:rgb_number(a:r) + let l:y = s:rgb_number(a:g) + let l:z = s:rgb_number(a:b) + + if l:gx == l:gy && l:gy == l:gz + " There are two possibilities + let l:dgr = s:grey_level(l:gx) - a:r + let l:dgg = s:grey_level(l:gy) - a:g + let l:dgb = s:grey_level(l:gz) - a:b + let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) + let l:dr = s:rgb_level(l:gx) - a:r + let l:dg = s:rgb_level(l:gy) - a:g + let l:db = s:rgb_level(l:gz) - a:b + let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) + if l:dgrey < l:drgb + " Use the grey + return s:grey_color(l:gx) + else + " Use the color + return s:rgb_color(l:x, l:y, l:z) + endif + else + " Only one possibility + return s:rgb_color(l:x, l:y, l:z) + endif + endfunction + + " Returns the palette index to approximate the '#rrggbb' hex string + function! s:rgb(rgb) + let l:r = ("0x" . strpart(a:rgb, 1, 2)) + 0 + let l:g = ("0x" . strpart(a:rgb, 3, 2)) + 0 + let l:b = ("0x" . strpart(a:rgb, 5, 2)) + 0 + + return s:color(l:r, l:g, l:b) + endfunction + + function! lightline#colorscheme#PaperColor#X(color) + return [a:color, s:rgb(a:color)] + endfunction + +if &background ==# 'light' + let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_light#palette +else + let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_dark#palette +endif + diff --git a/autoload/lightline/colorscheme/PaperColor_dark.vim b/autoload/lightline/colorscheme/PaperColor_dark.vim index e53a0ce..8173c4b 100644 --- a/autoload/lightline/colorscheme/PaperColor_dark.vim +++ b/autoload/lightline/colorscheme/PaperColor_dark.vim @@ -1,242 +1,45 @@ " ============================================================================= -" Filename: autoload/lightline/colorscheme/autoload/lightline/colorscheme/papercolor_light.vim +" Filename: autoload/lightline/colorscheme/PaperColor_dark.vim " Author: TKNGUE " License: MIT License -" Last Change: 2015/07/21 13:18:03 +" Last Change: 2015-07-27 06:01 " ============================================================================= -fun! grey_number(x) "{{{ - if &t_Co == 88 - if a:x < 23 - return 0 - elseif a:x < 69 - return 1 - elseif a:x < 103 - return 2 - elseif a:x < 127 - return 3 - elseif a:x < 150 - return 4 - elseif a:x < 173 - return 5 - elseif a:x < 196 - return 6 - elseif a:x < 219 - return 7 - elseif a:x < 243 - return 8 - else - return 9 - endif - else - if a:x < 14 - return 0 - else - let l:n = (a:x - 8) / 10 - let l:m = (a:x - 8) % 10 - if l:m < 5 - return l:n - else - return l:n + 1 - endif - endif - endif - endfun"}}} +let s:red = lightline#colorscheme#PaperColor#X("#df0000") +let s:green = lightline#colorscheme#PaperColor#X("#008700") +let s:blue = lightline#colorscheme#PaperColor#X("#00afaf") - " Returns the actual grey level represented by the grey index - fun! grey_level(n)"{{{ - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 46 - elseif a:n == 2 - return 92 - elseif a:n == 3 - return 115 - elseif a:n == 4 - return 139 - elseif a:n == 5 - return 162 - elseif a:n == 6 - return 185 - elseif a:n == 7 - return 208 - elseif a:n == 8 - return 231 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 8 + (a:n * 10) - endif - endif - endfun"}}} +let s:pink = lightline#colorscheme#PaperColor#X("#afdf00") +let s:olive = lightline#colorscheme#PaperColor#X("#dfaf5f") +let s:navy = lightline#colorscheme#PaperColor#X("#df875f") - " Returns the palette index for the given grey index - fun! grey_colour(n)"{{{ - if &t_Co == 88 - if a:n == 0 - return 16 - elseif a:n == 9 - return 79 - else - return 79 + a:n - endif - else - if a:n == 0 - return 16 - elseif a:n == 25 - return 231 - else - return 231 + a:n - endif - endif - endfun"}}} - - " Returns an approximate colour index for the given colour level - fun! rgb_number(x)"{{{ - if &t_Co == 88 - if a:x < 69 - return 0 - elseif a:x < 172 - return 1 - elseif a:x < 230 - return 2 - else - return 3 - endif - else - if a:x < 75 - return 0 - else - let l:n = (a:x - 55) / 40 - let l:m = (a:x - 55) % 40 - if l:m < 20 - return l:n - else - return l:n + 1 - endif - endif - endif - endfun"}}} - - " Returns the actual colour level for the given colour index - fun! rgb_level(n)"{{{ - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 139 - elseif a:n == 2 - return 205 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 55 + (a:n * 40) - endif - endif - endfun"}}} - - " Returns the palette index for the given R/G/B colour indices - fun! rgb_colour(x, y, z)"{{{ - if &t_Co == 88 - return 16 + (a:x * 16) + (a:y * 4) + a:z - else - return 16 + (a:x * 36) + (a:y * 6) + a:z - endif - endfun"}}} - - " Returns the palette index to approximate the given R/G/B colour levels - fun! colour(r, g, b)"{{{ - " Get the closest grey - let l:gx = grey_number(a:r) - let l:gy = grey_number(a:g) - let l:gz = grey_number(a:b) - - " Get the closest colour - let l:x = rgb_number(a:r) - let l:y = rgb_number(a:g) - let l:z = rgb_number(a:b) - - if l:gx == l:gy && l:gy == l:gz - " There are two possibilities - let l:dgr = grey_level(l:gx) - a:r - let l:dgg = grey_level(l:gy) - a:g - let l:dgb = grey_level(l:gz) - a:b - let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) - let l:dr = rgb_level(l:gx) - a:r - let l:dg = rgb_level(l:gy) - a:g - let l:db = rgb_level(l:gz) - a:b - let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) - if l:dgrey < l:drgb - " Use the grey - return grey_colour(l:gx) - else - " Use the colour - return rgb_colour(l:x, l:y, l:z) - endif - else - " Only one possibility - return rgb_colour(l:x, l:y, l:z) - endif - endfun"}}} - - " Returns the palette index to approximate the '#rrggbb' hex string - fun! rgb(rgb)"{{{ - let l:r = ("0x" . strpart(a:rgb, 1, 2)) + 0 - let l:g = ("0x" . strpart(a:rgb, 3, 2)) + 0 - let l:b = ("0x" . strpart(a:rgb, 5, 2)) + 0 - - return colour(l:r, l:g, l:b) - endfun"}}} - - fun! X(color)"{{{ - return [a:color, rgb(a:color)] - endfun"}}} - -let s:red = X("#df0000") -let s:green = X("#008700") -let s:blue = X("#00afaf") - -let s:pink = X("#afdf00") -let s:olive = X("#dfaf5f") -let s:navy = X("#df875f") - -let s:orange = X("#d75f00") -let s:purple = X("#8959a8") -let s:aqua = X("#3e999f") +let s:orange = lightline#colorscheme#PaperColor#X("#d75f00") +let s:purple = lightline#colorscheme#PaperColor#X("#8959a8") +let s:aqua = lightline#colorscheme#PaperColor#X("#3e999f") " Basics: -let s:foreground = X("#d0d0d0") -let s:background = X("#444444") -let s:window = X("#efefef") -let s:status = X("#c6c6c6") -let s:error = X("#5f0000") +let s:foreground = lightline#colorscheme#PaperColor#X("#d0d0d0") +let s:background = lightline#colorscheme#PaperColor#X("#444444") +let s:window = lightline#colorscheme#PaperColor#X("#efefef") +let s:status = lightline#colorscheme#PaperColor#X("#c6c6c6") +let s:error = lightline#colorscheme#PaperColor#X("#5f0000") " Tabline: -let s:tabline_bg = X("#3a3a3a") -let s:tabline_active_fg = X("#1c1c1c") -let s:tabline_active_bg = X("#00afaf") -let s:tabline_inactive_fg = X("#c6c6c6") -let s:tabline_inactive_bg = X("#585858") +let s:tabline_bg = lightline#colorscheme#PaperColor#X("#3a3a3a") +let s:tabline_active_fg = lightline#colorscheme#PaperColor#X("#1c1c1c") +let s:tabline_active_bg = lightline#colorscheme#PaperColor#X("#00afaf") +let s:tabline_inactive_fg = lightline#colorscheme#PaperColor#X("#c6c6c6") +let s:tabline_inactive_bg = lightline#colorscheme#PaperColor#X("#585858") " Statusline: -let s:statusline_active_fg = X("#1c1c1c") -let s:statusline_active_bg = X("#5f8787") -let s:statusline_inactive_fg = X("#c6c6c6") -let s:statusline_inactive_bg = X("#444444") +let s:statusline_active_fg = lightline#colorscheme#PaperColor#X("#1c1c1c") +let s:statusline_active_bg = lightline#colorscheme#PaperColor#X("#5f8787") +let s:statusline_inactive_fg = lightline#colorscheme#PaperColor#X("#c6c6c6") +let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#X("#444444") " Visual: -let s:visual_fg = X("#000000") -let s:visual_bg = X("#8787af") +let s:visual_fg = lightline#colorscheme#PaperColor#X("#000000") +let s:visual_bg = lightline#colorscheme#PaperColor#X("#8787af") let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] @@ -254,4 +57,4 @@ let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] let s:p.tabline.right = copy(s:p.normal.right) let s:p.normal.error = [ [ s:background, s:error ] ] -let g:lightline#colorscheme#papercolor_dark#palette = lightline#colorscheme#flatten(s:p) +let g:lightline#colorscheme#PaperColor_dark#palette = lightline#colorscheme#flatten(s:p) diff --git a/autoload/lightline/colorscheme/PaperColor_light.vim b/autoload/lightline/colorscheme/PaperColor_light.vim index 0e441ee..6d9d797 100644 --- a/autoload/lightline/colorscheme/PaperColor_light.vim +++ b/autoload/lightline/colorscheme/PaperColor_light.vim @@ -1,226 +1,26 @@ " ============================================================================= -" Filename: autoload/lightline/colorscheme/autoload/lightline/colorscheme/papercolor_light.vim +" Filename: autoload/lightline/colorscheme/PaperColor_light.vim " Author: TKNGUE " License: MIT License -" Last Change: 2015/07/21 13:18:03 +" Last Change: 2015-07-27 06:010 " ============================================================================= - -fun! grey_number(x) "{{{ - if &t_Co == 88 - if a:x < 23 - return 0 - elseif a:x < 69 - return 1 - elseif a:x < 103 - return 2 - elseif a:x < 127 - return 3 - elseif a:x < 150 - return 4 - elseif a:x < 173 - return 5 - elseif a:x < 196 - return 6 - elseif a:x < 219 - return 7 - elseif a:x < 243 - return 8 - else - return 9 - endif - else - if a:x < 14 - return 0 - else - let l:n = (a:x - 8) / 10 - let l:m = (a:x - 8) % 10 - if l:m < 5 - return l:n - else - return l:n + 1 - endif - endif - endif - endfun"}}} - - " Returns the actual grey level represented by the grey index - fun! grey_level(n)"{{{ - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 46 - elseif a:n == 2 - return 92 - elseif a:n == 3 - return 115 - elseif a:n == 4 - return 139 - elseif a:n == 5 - return 162 - elseif a:n == 6 - return 185 - elseif a:n == 7 - return 208 - elseif a:n == 8 - return 231 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 8 + (a:n * 10) - endif - endif - endfun"}}} - - " Returns the palette index for the given grey index - fun! grey_colour(n)"{{{ - if &t_Co == 88 - if a:n == 0 - return 16 - elseif a:n == 9 - return 79 - else - return 79 + a:n - endif - else - if a:n == 0 - return 16 - elseif a:n == 25 - return 231 - else - return 231 + a:n - endif - endif - endfun"}}} - - " Returns an approximate colour index for the given colour level - fun! rgb_number(x)"{{{ - if &t_Co == 88 - if a:x < 69 - return 0 - elseif a:x < 172 - return 1 - elseif a:x < 230 - return 2 - else - return 3 - endif - else - if a:x < 75 - return 0 - else - let l:n = (a:x - 55) / 40 - let l:m = (a:x - 55) % 40 - if l:m < 20 - return l:n - else - return l:n + 1 - endif - endif - endif - endfun"}}} - - " Returns the actual colour level for the given colour index - fun! rgb_level(n)"{{{ - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 139 - elseif a:n == 2 - return 205 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 55 + (a:n * 40) - endif - endif - endfun"}}} - - " Returns the palette index for the given R/G/B colour indices - fun! rgb_colour(x, y, z)"{{{ - if &t_Co == 88 - return 16 + (a:x * 16) + (a:y * 4) + a:z - else - return 16 + (a:x * 36) + (a:y * 6) + a:z - endif - endfun"}}} - - " Returns the palette index to approximate the given R/G/B colour levels - fun! colour(r, g, b)"{{{ - " Get the closest grey - let l:gx = grey_number(a:r) - let l:gy = grey_number(a:g) - let l:gz = grey_number(a:b) - - " Get the closest colour - let l:x = rgb_number(a:r) - let l:y = rgb_number(a:g) - let l:z = rgb_number(a:b) - - if l:gx == l:gy && l:gy == l:gz - " There are two possibilities - let l:dgr = grey_level(l:gx) - a:r - let l:dgg = grey_level(l:gy) - a:g - let l:dgb = grey_level(l:gz) - a:b - let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) - let l:dr = rgb_level(l:gx) - a:r - let l:dg = rgb_level(l:gy) - a:g - let l:db = rgb_level(l:gz) - a:b - let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) - if l:dgrey < l:drgb - " Use the grey - return grey_colour(l:gx) - else - " Use the colour - return rgb_colour(l:x, l:y, l:z) - endif - else - " Only one possibility - return rgb_colour(l:x, l:y, l:z) - endif - endfun"}}} - - " Returns the palette index to approximate the '#rrggbb' hex string - fun! rgb(rgb)"{{{ - let l:r = ("0x" . strpart(a:rgb, 1, 2)) + 0 - let l:g = ("0x" . strpart(a:rgb, 3, 2)) + 0 - let l:b = ("0x" . strpart(a:rgb, 5, 2)) + 0 - - return colour(l:r, l:g, l:b) - endfun"}}} - - fun! X(color)"{{{ - return [a:color, rgb(a:color)] - endfun"}}} - -let s:red = X("#df0000") "Include/Exception -let s:green = X("#008700") "Boolean/Special -let s:blue = X("#4271ae") "Keyword - -let s:pink = X("#d7005f") "Type -let s:olive = X("#718c00") "String -let s:navy = X("#005f87") "StorageClass - -let s:orange = X("#d75f00") "Number -let s:purple = X("#8959a8") "Repeat/Conditional -let s:aqua = X("#3e999f") "Operator/Delimiter +let s:red = lightline#colorscheme#PaperColor#X("#df0000") "Include/Exception +let s:green = lightline#colorscheme#PaperColor#X("#008700") "Boolean/Special +let s:blue = lightline#colorscheme#PaperColor#X("#4271ae") "Keyword +let s:pink = lightline#colorscheme#PaperColor#X("#d7005f") "Type +let s:olive = lightline#colorscheme#PaperColor#X("#718c00") "String +let s:navy = lightline#colorscheme#PaperColor#X("#005f87") "StorageClass +let s:orange = lightline#colorscheme#PaperColor#X("#d75f00") "Number +let s:purple = lightline#colorscheme#PaperColor#X("#8959a8") "Repeat/Conditional +let s:aqua = lightline#colorscheme#PaperColor#X("#3e999f") "Operator/Delimiter " Basics: -let s:foreground = X("#4d4d4c") -let s:background = X("#F5F5F5") -let s:window = X("#efefef") +let s:foreground = lightline#colorscheme#PaperColor#X("#4d4d4c") +let s:background = lightline#colorscheme#PaperColor#X("#F5F5F5") +let s:window = lightline#colorscheme#PaperColor#X("#efefef") let s:status = s:aqua -let s:error = X("#ffafdf") +let s:error = lightline#colorscheme#PaperColor#X("#ffafdf") " Tabline: let s:tabline_bg = s:navy @@ -233,7 +33,7 @@ let s:tabline_inactive_bg = s:aqua let s:statusline_active_fg = s:window let s:statusline_active_bg = s:navy let s:statusline_inactive_fg = s:foreground -let s:statusline_inactive_bg = X("#dadada") +let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#X("#dadada") " Visual: let s:visual_fg = s:background @@ -256,4 +56,4 @@ let s:p.tabline.right = copy(s:p.normal.right) let s:p.normal.error = [ [ s:background, s:error ] ] let s:p.normal.warning = [ [ s:background, s:olive ] ] -let g:lightline#colorscheme#papercolor_light#palette = lightline#colorscheme#flatten(s:p) +let g:lightline#colorscheme#PaperColor_light#palette = lightline#colorscheme#flatten(s:p) From bb8be60d94b313547f83718f2e36e774784ad634 Mon Sep 17 00:00:00 2001 From: TKNGUE Date: Mon, 27 Jul 2015 17:40:31 +0900 Subject: [PATCH 6/6] Reafactor codes - rename function names. - remove local variable annotation. --- autoload/lightline/colorscheme/PaperColor.vim | 66 +++++++++---------- .../lightline/colorscheme/PaperColor_dark.vim | 50 +++++++------- .../colorscheme/PaperColor_light.vim | 28 ++++---- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/autoload/lightline/colorscheme/PaperColor.vim b/autoload/lightline/colorscheme/PaperColor.vim index 7c568d3..2b5ab55 100644 --- a/autoload/lightline/colorscheme/PaperColor.vim +++ b/autoload/lightline/colorscheme/PaperColor.vim @@ -31,12 +31,12 @@ if a:x < 14 return 0 else - let l:n = (a:x - 8) / 10 - let l:m = (a:x - 8) % 10 - if l:m < 5 - return l:n + let n = (a:x - 8) / 10 + let m = (a:x - 8) % 10 + if m < 5 + return n else - return l:n + 1 + return n + 1 endif endif endif @@ -112,12 +112,12 @@ if a:x < 75 return 0 else - let l:n = (a:x - 55) / 40 - let l:m = (a:x - 55) % 40 - if l:m < 20 - return l:n + let n = (a:x - 55) / 40 + let m = (a:x - 55) % 40 + if m < 20 + return n else - return l:n + 1 + return n + 1 endif endif endif @@ -156,45 +156,45 @@ " Returns the palette index to approximate the given R/G/B color levels function! s:color(r, g, b) " Get the closest grey - let l:gx = s:grey_number(a:r) - let l:gy = s:grey_number(a:g) - let l:gz = s:grey_number(a:b) + let gx = s:grey_number(a:r) + let gy = s:grey_number(a:g) + let gz = s:grey_number(a:b) " Get the closest color - let l:x = s:rgb_number(a:r) - let l:y = s:rgb_number(a:g) - let l:z = s:rgb_number(a:b) + let x = s:rgb_number(a:r) + let y = s:rgb_number(a:g) + let z = s:rgb_number(a:b) - if l:gx == l:gy && l:gy == l:gz + if gx == gy && gy == gz " There are two possibilities - let l:dgr = s:grey_level(l:gx) - a:r - let l:dgg = s:grey_level(l:gy) - a:g - let l:dgb = s:grey_level(l:gz) - a:b - let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) - let l:dr = s:rgb_level(l:gx) - a:r - let l:dg = s:rgb_level(l:gy) - a:g - let l:db = s:rgb_level(l:gz) - a:b - let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) - if l:dgrey < l:drgb + let dgr = s:grey_level(gx) - a:r + let dgg = s:grey_level(gy) - a:g + let dgb = s:grey_level(gz) - a:b + let dgrey = (dgr * dgr) + (dgg * dgg) + (dgb * dgb) + let dr = s:rgb_level(gx) - a:r + let dg = s:rgb_level(gy) - a:g + let db = s:rgb_level(gz) - a:b + let drgb = (dr * dr) + (dg * dg) + (db * db) + if dgrey < drgb " Use the grey - return s:grey_color(l:gx) + return s:grey_color(gx) else " Use the color - return s:rgb_color(l:x, l:y, l:z) + return s:rgb_color(x, y, z) endif else " Only one possibility - return s:rgb_color(l:x, l:y, l:z) + return s:rgb_color(x, y, z) endif endfunction " Returns the palette index to approximate the '#rrggbb' hex string function! s:rgb(rgb) - let l:r = ("0x" . strpart(a:rgb, 1, 2)) + 0 - let l:g = ("0x" . strpart(a:rgb, 3, 2)) + 0 - let l:b = ("0x" . strpart(a:rgb, 5, 2)) + 0 + let r = ("0x" . strpart(a:rgb, 1, 2)) + 0 + let g = ("0x" . strpart(a:rgb, 3, 2)) + 0 + let b = ("0x" . strpart(a:rgb, 5, 2)) + 0 - return s:color(l:r, l:g, l:b) + return s:color(r, g, b) endfunction function! lightline#colorscheme#PaperColor#X(color) diff --git a/autoload/lightline/colorscheme/PaperColor_dark.vim b/autoload/lightline/colorscheme/PaperColor_dark.vim index 8173c4b..b0af411 100644 --- a/autoload/lightline/colorscheme/PaperColor_dark.vim +++ b/autoload/lightline/colorscheme/PaperColor_dark.vim @@ -5,41 +5,41 @@ " Last Change: 2015-07-27 06:01 " ============================================================================= -let s:red = lightline#colorscheme#PaperColor#X("#df0000") -let s:green = lightline#colorscheme#PaperColor#X("#008700") -let s:blue = lightline#colorscheme#PaperColor#X("#00afaf") +let s:red = lightline#colorscheme#PaperColor#color_set("#df0000") +let s:green = lightline#colorscheme#PaperColor#color_set("#008700") +let s:blue = lightline#colorscheme#PaperColor#color_set("#00afaf") -let s:pink = lightline#colorscheme#PaperColor#X("#afdf00") -let s:olive = lightline#colorscheme#PaperColor#X("#dfaf5f") -let s:navy = lightline#colorscheme#PaperColor#X("#df875f") +let s:pink = lightline#colorscheme#PaperColor#color_set("#afdf00") +let s:olive = lightline#colorscheme#PaperColor#color_set("#dfaf5f") +let s:navy = lightline#colorscheme#PaperColor#color_set("#df875f") -let s:orange = lightline#colorscheme#PaperColor#X("#d75f00") -let s:purple = lightline#colorscheme#PaperColor#X("#8959a8") -let s:aqua = lightline#colorscheme#PaperColor#X("#3e999f") +let s:orange = lightline#colorscheme#PaperColor#color_set("#d75f00") +let s:purple = lightline#colorscheme#PaperColor#color_set("#8959a8") +let s:aqua = lightline#colorscheme#PaperColor#color_set("#3e999f") " Basics: -let s:foreground = lightline#colorscheme#PaperColor#X("#d0d0d0") -let s:background = lightline#colorscheme#PaperColor#X("#444444") -let s:window = lightline#colorscheme#PaperColor#X("#efefef") -let s:status = lightline#colorscheme#PaperColor#X("#c6c6c6") -let s:error = lightline#colorscheme#PaperColor#X("#5f0000") +let s:foreground = lightline#colorscheme#PaperColor#color_set("#d0d0d0") +let s:background = lightline#colorscheme#PaperColor#color_set("#444444") +let s:window = lightline#colorscheme#PaperColor#color_set("#efefef") +let s:status = lightline#colorscheme#PaperColor#color_set("#c6c6c6") +let s:error = lightline#colorscheme#PaperColor#color_set("#5f0000") " Tabline: -let s:tabline_bg = lightline#colorscheme#PaperColor#X("#3a3a3a") -let s:tabline_active_fg = lightline#colorscheme#PaperColor#X("#1c1c1c") -let s:tabline_active_bg = lightline#colorscheme#PaperColor#X("#00afaf") -let s:tabline_inactive_fg = lightline#colorscheme#PaperColor#X("#c6c6c6") -let s:tabline_inactive_bg = lightline#colorscheme#PaperColor#X("#585858") +let s:tabline_bg = lightline#colorscheme#PaperColor#color_set("#3a3a3a") +let s:tabline_active_fg = lightline#colorscheme#PaperColor#color_set("#1c1c1c") +let s:tabline_active_bg = lightline#colorscheme#PaperColor#color_set("#00afaf") +let s:tabline_inactive_fg = lightline#colorscheme#PaperColor#color_set("#c6c6c6") +let s:tabline_inactive_bg = lightline#colorscheme#PaperColor#color_set("#585858") " Statusline: -let s:statusline_active_fg = lightline#colorscheme#PaperColor#X("#1c1c1c") -let s:statusline_active_bg = lightline#colorscheme#PaperColor#X("#5f8787") -let s:statusline_inactive_fg = lightline#colorscheme#PaperColor#X("#c6c6c6") -let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#X("#444444") +let s:statusline_active_fg = lightline#colorscheme#PaperColor#color_set("#1c1c1c") +let s:statusline_active_bg = lightline#colorscheme#PaperColor#color_set("#5f8787") +let s:statusline_inactive_fg = lightline#colorscheme#PaperColor#color_set("#c6c6c6") +let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#color_set("#444444") " Visual: -let s:visual_fg = lightline#colorscheme#PaperColor#X("#000000") -let s:visual_bg = lightline#colorscheme#PaperColor#X("#8787af") +let s:visual_fg = lightline#colorscheme#PaperColor#color_set("#000000") +let s:visual_bg = lightline#colorscheme#PaperColor#color_set("#8787af") let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] diff --git a/autoload/lightline/colorscheme/PaperColor_light.vim b/autoload/lightline/colorscheme/PaperColor_light.vim index 6d9d797..3176591 100644 --- a/autoload/lightline/colorscheme/PaperColor_light.vim +++ b/autoload/lightline/colorscheme/PaperColor_light.vim @@ -4,23 +4,23 @@ " License: MIT License " Last Change: 2015-07-27 06:010 " ============================================================================= -let s:red = lightline#colorscheme#PaperColor#X("#df0000") "Include/Exception -let s:green = lightline#colorscheme#PaperColor#X("#008700") "Boolean/Special -let s:blue = lightline#colorscheme#PaperColor#X("#4271ae") "Keyword -let s:pink = lightline#colorscheme#PaperColor#X("#d7005f") "Type -let s:olive = lightline#colorscheme#PaperColor#X("#718c00") "String -let s:navy = lightline#colorscheme#PaperColor#X("#005f87") "StorageClass -let s:orange = lightline#colorscheme#PaperColor#X("#d75f00") "Number -let s:purple = lightline#colorscheme#PaperColor#X("#8959a8") "Repeat/Conditional -let s:aqua = lightline#colorscheme#PaperColor#X("#3e999f") "Operator/Delimiter +let s:red = lightline#colorscheme#PaperColor#color_set("#df0000") "Include/Exception +let s:green = lightline#colorscheme#PaperColor#color_set("#008700") "Boolean/Special +let s:blue = lightline#colorscheme#PaperColor#color_set("#4271ae") "Keyword +let s:pink = lightline#colorscheme#PaperColor#color_set("#d7005f") "Type +let s:olive = lightline#colorscheme#PaperColor#color_set("#718c00") "String +let s:navy = lightline#colorscheme#PaperColor#color_set("#005f87") "StorageClass +let s:orange = lightline#colorscheme#PaperColor#color_set("#d75f00") "Number +let s:purple = lightline#colorscheme#PaperColor#color_set("#8959a8") "Repeat/Conditional +let s:aqua = lightline#colorscheme#PaperColor#color_set("#3e999f") "Operator/Delimiter " Basics: -let s:foreground = lightline#colorscheme#PaperColor#X("#4d4d4c") -let s:background = lightline#colorscheme#PaperColor#X("#F5F5F5") -let s:window = lightline#colorscheme#PaperColor#X("#efefef") +let s:foreground = lightline#colorscheme#PaperColor#color_set("#4d4d4c") +let s:background = lightline#colorscheme#PaperColor#color_set("#F5F5F5") +let s:window = lightline#colorscheme#PaperColor#color_set("#efefef") let s:status = s:aqua -let s:error = lightline#colorscheme#PaperColor#X("#ffafdf") +let s:error = lightline#colorscheme#PaperColor#color_set("#ffafdf") " Tabline: let s:tabline_bg = s:navy @@ -33,7 +33,7 @@ let s:tabline_inactive_bg = s:aqua let s:statusline_active_fg = s:window let s:statusline_active_bg = s:navy let s:statusline_inactive_fg = s:foreground -let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#X("#dadada") +let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#color_set("#dadada") " Visual: let s:visual_fg = s:background