create automatic colorscheme generator

This commit is contained in:
Dmytro Meleshko 2019-08-24 19:05:09 +03:00
parent e477df7a15
commit 2325f94e1b
13 changed files with 561 additions and 51 deletions

54
colorschemes/_theme.py Normal file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env python
# base16-eighties by Chris Kempson (http://chriskempson.com)
base16_colors = [
"#2d2d2d", # 0
"#393939", # 1
"#515151", # 2
"#747369", # 3
"#a09f93", # 4
"#d3d0c8", # 5
"#e8e6df", # 6
"#f2f0ec", # 7
"#f2777a", # 8
"#f99157", # 9
"#ffcc66", # a
"#99cc99", # b
"#66cccc", # c
"#6699cc", # d
"#cc99cc", # e
"#d27b53", # f
]
bg = base16_colors[0x0]
fg = base16_colors[0x5]
cursor_bg = fg
cursor_fg = bg
selection_bg = base16_colors[0x2]
selection_fg = fg
ansi_colors = [
base16_colors[i]
for i in [
0x0,
0x8,
0xB,
0xA,
0xD,
0xE,
0xC,
0x5,
0x3,
0x8,
0xB,
0xA,
0xD,
0xE,
0xC,
0x7,
]
]
link_color = ansi_colors[12]

20
colorschemes/build.sh Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
mkdir -p out
declare -A apps=(
[nvim]=vim
[iterm]=itermcolors
[kitty]=conf
[termux]=properties
)
for app in "${!apps[@]}"; do
output_file="$app.${apps[$app]}"
echo "$output_file"
./"$app".py > ./out/"$output_file"
done

52
colorschemes/iterm.py Executable file
View file

@ -0,0 +1,52 @@
#!/usr/bin/env python
import _theme as theme
print(
"""\
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>\
"""
)
def print_color(key_name, color):
r, g, b = [float(int(color[2 * i + 1 : 2 * i + 3], 16)) / 255 for i in range(3)]
print(
"""\
<key>{} Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>{}</real>
<key>Green Component</key>
<real>{}</real>
<key>Blue Component</key>
<real>{}</real>
</dict>\
""".format(
key_name, r, g, b
)
)
print_color("Background", theme.bg)
print_color("Foreground", theme.fg)
print_color("Bold", theme.fg)
print_color("Cursor", theme.cursor_bg)
print_color("Cursor Text", theme.cursor_fg)
print_color("Selection Color", theme.selection_bg)
print_color("Selected Text Color", theme.selection_fg)
for index, color in enumerate(theme.ansi_colors):
print_color("Ansi " + str(index), color)
print_color("Link", theme.link_color)
print(
"""\
</dict>
</plist>\
"""
)

16
colorschemes/kitty.py Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env python
import _theme as theme
print("background", theme.bg)
print("foreground", theme.fg)
print("cursor", theme.cursor_bg)
print("cursor_text_color", theme.cursor_fg)
print("selection_background", theme.selection_bg)
print("selection_foreground", theme.selection_fg)
for index, color in enumerate(theme.ansi_colors):
print("color" + str(index), color)
print("url_color", theme.link_color)
print("active_border_color", theme.ansi_colors[2])
print("inactive_border_color", theme.ansi_colors[8])
print("bell_border_color", theme.ansi_colors[1])

19
colorschemes/nvim.py Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env python
import _theme as theme
print("let colorscheme_base16_colors = [")
gui_to_cterm_mapping = [0, 18, 19, 8, 20, 7, 21, 15, 1, 16, 3, 2, 6, 4, 5, 17]
for colors_pair in zip(theme.base16_colors, gui_to_cterm_mapping):
print("\\ {{'gui': '{}', 'cterm': '{:>02}'}},".format(*colors_pair))
print("\\ ]")
def print_terminal_color(key_name, color):
print("let terminal_color_{} = '{}'".format(key_name, color))
print_terminal_color("background", theme.bg)
print_terminal_color("foreground", theme.fg)
for index, color in enumerate(theme.ansi_colors):
print_terminal_color(str(index), color)

View file

@ -0,0 +1,270 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Background Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.17647058823529413</real>
<key>Green Component</key>
<real>0.17647058823529413</real>
<key>Blue Component</key>
<real>0.17647058823529413</real>
</dict>
<key>Foreground Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8274509803921568</real>
<key>Green Component</key>
<real>0.8156862745098039</real>
<key>Blue Component</key>
<real>0.7843137254901961</real>
</dict>
<key>Bold Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8274509803921568</real>
<key>Green Component</key>
<real>0.8156862745098039</real>
<key>Blue Component</key>
<real>0.7843137254901961</real>
</dict>
<key>Cursor Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8274509803921568</real>
<key>Green Component</key>
<real>0.8156862745098039</real>
<key>Blue Component</key>
<real>0.7843137254901961</real>
</dict>
<key>Cursor Text Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.17647058823529413</real>
<key>Green Component</key>
<real>0.17647058823529413</real>
<key>Blue Component</key>
<real>0.17647058823529413</real>
</dict>
<key>Selection Color Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.3176470588235294</real>
<key>Green Component</key>
<real>0.3176470588235294</real>
<key>Blue Component</key>
<real>0.3176470588235294</real>
</dict>
<key>Selected Text Color Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8274509803921568</real>
<key>Green Component</key>
<real>0.8156862745098039</real>
<key>Blue Component</key>
<real>0.7843137254901961</real>
</dict>
<key>Ansi 0 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.17647058823529413</real>
<key>Green Component</key>
<real>0.17647058823529413</real>
<key>Blue Component</key>
<real>0.17647058823529413</real>
</dict>
<key>Ansi 1 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.9490196078431372</real>
<key>Green Component</key>
<real>0.4666666666666667</real>
<key>Blue Component</key>
<real>0.47843137254901963</real>
</dict>
<key>Ansi 2 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.6</real>
<key>Green Component</key>
<real>0.8</real>
<key>Blue Component</key>
<real>0.6</real>
</dict>
<key>Ansi 3 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>1.0</real>
<key>Green Component</key>
<real>0.8</real>
<key>Blue Component</key>
<real>0.4</real>
</dict>
<key>Ansi 4 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.4</real>
<key>Green Component</key>
<real>0.6</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
<key>Ansi 5 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8</real>
<key>Green Component</key>
<real>0.6</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
<key>Ansi 6 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.4</real>
<key>Green Component</key>
<real>0.8</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
<key>Ansi 7 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8274509803921568</real>
<key>Green Component</key>
<real>0.8156862745098039</real>
<key>Blue Component</key>
<real>0.7843137254901961</real>
</dict>
<key>Ansi 8 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.4549019607843137</real>
<key>Green Component</key>
<real>0.45098039215686275</real>
<key>Blue Component</key>
<real>0.4117647058823529</real>
</dict>
<key>Ansi 9 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.9490196078431372</real>
<key>Green Component</key>
<real>0.4666666666666667</real>
<key>Blue Component</key>
<real>0.47843137254901963</real>
</dict>
<key>Ansi 10 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.6</real>
<key>Green Component</key>
<real>0.8</real>
<key>Blue Component</key>
<real>0.6</real>
</dict>
<key>Ansi 11 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>1.0</real>
<key>Green Component</key>
<real>0.8</real>
<key>Blue Component</key>
<real>0.4</real>
</dict>
<key>Ansi 12 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.4</real>
<key>Green Component</key>
<real>0.6</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
<key>Ansi 13 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.8</real>
<key>Green Component</key>
<real>0.6</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
<key>Ansi 14 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.4</real>
<key>Green Component</key>
<real>0.8</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
<key>Ansi 15 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.9490196078431372</real>
<key>Green Component</key>
<real>0.9411764705882353</real>
<key>Blue Component</key>
<real>0.9254901960784314</real>
</dict>
<key>Link Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Red Component</key>
<real>0.4</real>
<key>Green Component</key>
<real>0.6</real>
<key>Blue Component</key>
<real>0.8</real>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,26 @@
background #2d2d2d
foreground #d3d0c8
cursor #d3d0c8
cursor_text_color #2d2d2d
selection_background #515151
selection_foreground #d3d0c8
color0 #2d2d2d
color1 #f2777a
color2 #99cc99
color3 #ffcc66
color4 #6699cc
color5 #cc99cc
color6 #66cccc
color7 #d3d0c8
color8 #747369
color9 #f2777a
color10 #99cc99
color11 #ffcc66
color12 #6699cc
color13 #cc99cc
color14 #66cccc
color15 #f2f0ec
url_color #6699cc
active_border_color #99cc99
inactive_border_color #747369
bell_border_color #f2777a

36
colorschemes/out/nvim.vim Normal file
View file

@ -0,0 +1,36 @@
let colorscheme_base16_colors = [
\ {'gui': '#2d2d2d', 'cterm': '00'},
\ {'gui': '#393939', 'cterm': '18'},
\ {'gui': '#515151', 'cterm': '19'},
\ {'gui': '#747369', 'cterm': '08'},
\ {'gui': '#a09f93', 'cterm': '20'},
\ {'gui': '#d3d0c8', 'cterm': '07'},
\ {'gui': '#e8e6df', 'cterm': '21'},
\ {'gui': '#f2f0ec', 'cterm': '15'},
\ {'gui': '#f2777a', 'cterm': '01'},
\ {'gui': '#f99157', 'cterm': '16'},
\ {'gui': '#ffcc66', 'cterm': '03'},
\ {'gui': '#99cc99', 'cterm': '02'},
\ {'gui': '#66cccc', 'cterm': '06'},
\ {'gui': '#6699cc', 'cterm': '04'},
\ {'gui': '#cc99cc', 'cterm': '05'},
\ {'gui': '#d27b53', 'cterm': '17'},
\ ]
let terminal_color_background = '#2d2d2d'
let terminal_color_foreground = '#d3d0c8'
let terminal_color_0 = '#2d2d2d'
let terminal_color_1 = '#f2777a'
let terminal_color_2 = '#99cc99'
let terminal_color_3 = '#ffcc66'
let terminal_color_4 = '#6699cc'
let terminal_color_5 = '#cc99cc'
let terminal_color_6 = '#66cccc'
let terminal_color_7 = '#d3d0c8'
let terminal_color_8 = '#747369'
let terminal_color_9 = '#f2777a'
let terminal_color_10 = '#99cc99'
let terminal_color_11 = '#ffcc66'
let terminal_color_12 = '#6699cc'
let terminal_color_13 = '#cc99cc'
let terminal_color_14 = '#66cccc'
let terminal_color_15 = '#f2f0ec'

View file

@ -0,0 +1,19 @@
background=#2d2d2d
foreground=#d3d0c8
cursor=#d3d0c8
color0=#2d2d2d
color1=#f2777a
color2=#99cc99
color3=#ffcc66
color4=#6699cc
color5=#cc99cc
color6=#66cccc
color7=#d3d0c8
color8=#747369
color9=#f2777a
color10=#99cc99
color11=#ffcc66
color12=#6699cc
color13=#cc99cc
color14=#66cccc
color15=#f2f0ec

14
colorschemes/termux.py Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env python
import _theme as theme
def print_color(key_name, color):
print("{}={}".format(key_name, color))
print_color("background", theme.bg)
print_color("foreground", theme.fg)
print_color("cursor", theme.cursor_bg)
for index, color in enumerate(theme.ansi_colors):
print_color("color" + str(index), color)

View file

@ -1,4 +1,4 @@
# vim:fileencoding=utf-8:ft=conf:foldmethod=marker
include ../colorschemes/out/kitty.conf
#: Fonts {{{
@ -6,7 +6,7 @@
#: individual font faces and even specify special fonts for particular
#: characters.
font_family Ubuntu Mono derivative Powerline
# font_family monospace
# bold_font auto
# italic_font auto
# bold_italic_font auto
@ -59,11 +59,11 @@ font_family Ubuntu Mono derivative Powerline
#: Cursor customization {{{
cursor #d3d0c8
# cursor #cccccc
#: Default cursor color
cursor_text_color #2d2d2d
# cursor_text_color #111111
#: Choose the color of text under the cursor. If you want it rendered
#: with the background color of the cell underneath instead, use the
@ -114,7 +114,7 @@ cursor_stop_blinking_after 0
#: Mouse {{{
url_color #6699cc
# url_color #0087bd
url_style single
#: The color and style for highlighting URLs on mouse-over. url_style
@ -281,15 +281,15 @@ window_padding_width 2.0
#: The window padding (in pts) (blank area between the text and the
#: window border)
active_border_color #99cc99
# active_border_color #00ff00
#: The color for the border of the active window
inactive_border_color #747369
# inactive_border_color #cccccc
#: The color for the border of inactive windows
bell_border_color #f2777a
# bell_border_color #ff5a00
#: The color for the border of inactive windows in which a bell has
#: occurred
@ -346,8 +346,8 @@ inactive_tab_font_style italic
#: Color scheme {{{
foreground #d3d0c8
background #2d2d2d
# foreground #dddddd
# background #000000
#: The foreground and background colors
@ -375,8 +375,8 @@ background #2d2d2d
#: How much to dim text that has the DIM/FAINT attribute set. One
#: means no dimming and zero means fully dimmed (i.e. invisible).
selection_foreground #d3d0c8
selection_background #515151
# selection_foreground #000000
# selection_background #fffacd
#: The foreground and background for text selected with the mouse
@ -385,43 +385,43 @@ selection_background #515151
#: dull and bright version. You can also set the remaining colors from
#: the 256 color table as color16 to color255.
color0 #2d2d2d
color8 #747369
# color0 #000000
# color8 #767676
#: black
color1 #f2777a
color9 #f2777a
# color1 #cc0403
# color9 #f2201f
#: red
color2 #99cc99
color10 #99cc99
# color2 #19cb00
# color10 #23fd00
#: green
color3 #ffcc66
color11 #ffcc66
# color3 #cecb00
# color11 #fffd00
#: yellow
color4 #6699cc
color12 #6699cc
# color4 #0d73cc
# color12 #1a8fff
#: blue
color5 #cc99cc
color13 #cc99cc
# color5 #cb1ed1
# color13 #fd28ff
#: magenta
color6 #66cccc
color14 #66cccc
# color6 #0dcdcd
# color14 #14ffff
#: cyan
color7 #d3d0c8
color15 #f2f0ec
# color7 #dddddd
# color15 #ffffff
#: white

View file

@ -1,11 +1,11 @@
let s:my_config_dir = expand('<sfile>:p:h')
let g:nvim_dotfiles_dir = expand('<sfile>:p:h')
let g:vim_ide = get(g:, 'vim_ide', 0)
for s:name in ['plugins', 'editing', 'interface', 'colorscheme', 'files', 'completion', 'terminal', 'git']
execute 'source' fnameescape(s:my_config_dir.'/lib/'.s:name.'.vim')
execute 'source' fnameescape(g:nvim_dotfiles_dir.'/lib/'.s:name.'.vim')
endfor
for s:path in globpath(s:my_config_dir.'/lib/languages', '*', 0, 1)
for s:path in globpath(g:nvim_dotfiles_dir.'/lib/languages', '*', 0, 1)
execute 'source' fnameescape(s:path)
endfor

View file

@ -5,31 +5,15 @@ let s:base16_theme_name = 'eighties'
" Color definitions {{{
if empty($BASE16_SHELL) || !filereadable($BASE16_SHELL . '/scripts/base16-' . s:base16_theme_name . '.sh') || &termguicolors
if empty($BASE16_SHELL) || !filereadable($BASE16_SHELL.'/scripts/base16-'.s:base16_theme_name.'.sh') || &termguicolors
set termguicolors
else
" call system(shellescape(s:base16_shell_script))
endif
" Eighties scheme by Chris Kempson (http://chriskempson.com)
let s:colors = [
\ {'gui': '#2d2d2d', 'cterm': '00'},
\ {'gui': '#393939', 'cterm': '18'},
\ {'gui': '#515151', 'cterm': '19'},
\ {'gui': '#747369', 'cterm': '08'},
\ {'gui': '#a09f93', 'cterm': '20'},
\ {'gui': '#d3d0c8', 'cterm': '07'},
\ {'gui': '#e8e6df', 'cterm': '21'},
\ {'gui': '#f2f0ec', 'cterm': '15'},
\ {'gui': '#f2777a', 'cterm': '01'},
\ {'gui': '#f99157', 'cterm': '16'},
\ {'gui': '#ffcc66', 'cterm': '03'},
\ {'gui': '#99cc99', 'cterm': '02'},
\ {'gui': '#66cccc', 'cterm': '06'},
\ {'gui': '#6699cc', 'cterm': '04'},
\ {'gui': '#cc99cc', 'cterm': '05'},
\ {'gui': '#d27b53', 'cterm': '17'}
\ ]
execute 'source' fnameescape(g:nvim_dotfiles_dir.'/../colorschemes/out/nvim.vim')
let s:colors = g:colorscheme_base16_colors
unlet g:colorscheme_base16_colors
" }}}