Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve startup time by hard-coding the 256 color #93

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 103 additions & 75 deletions colors/one.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

if exists("*<SID>X")
delf <SID>X
delf <SID>XAPI
delf <SID>rgb
delf <SID>color
delf <SID>rgb_color
Expand All @@ -28,6 +29,11 @@ if !exists('g:one_allow_italics')
let g:one_allow_italics = 0
endif

let s:italic = ''
if g:one_allow_italics == 1
let s:italic = 'italic'
endif

if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
" functions
" returns an approximate grey index for the given grey level
Expand Down Expand Up @@ -227,7 +233,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
endfun

" sets the highlighting for the given group
fun <sid>X(group, fg, bg, attr)
fun <SID>XAPI(group, fg, bg, attr)
let l:attr = a:attr
if g:one_allow_italics == 0 && l:attr ==? 'italic'
let l:attr= 'none'
Expand Down Expand Up @@ -257,73 +263,95 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256

endfun

"}}}
" Highlight function
" the original one is borrowed from mhartington/oceanic-next
function! <SID>X(group, fg, bg, attr, ...)
let l:attrsp = get(a:, 1, "")
" fg, bg, attr, attrsp
if !empty(a:fg)
exec "hi " . a:group . " guifg=" . a:fg[0]
exec "hi " . a:group . " ctermfg=" . a:fg[1]
endif
if !empty(a:bg)
exec "hi " . a:group . " guibg=" . a:bg[0]
exec "hi " . a:group . " ctermbg=" . a:bg[1]
endif
if a:attr != ""
exec "hi " . a:group . " gui=" . a:attr
exec "hi " . a:group . " cterm=" . a:attr
endif
if !empty(l:attrsp)
exec "hi " . a:group . " guisp=" . l:attrsp[0]
endif
endfunction

" }}}


" Color definition --------------------------------------------------------{{{
let s:dark = 0
if &background ==# 'dark'
let s:dark = 1
let s:mono_1 = 'abb2bf'
let s:mono_2 = '828997'
let s:mono_3 = '5c6370'
let s:mono_4 = '4b5263'
let s:mono_1 = ['#abb2bf', '145']
let s:mono_2 = ['#828997', '102']
let s:mono_3 = ['#5c6370', '59']
let s:mono_4 = ['#4b5263', '59']

let s:hue_1 = '56b6c2' " cyan
let s:hue_2 = '61afef' " blue
let s:hue_3 = 'c678dd' " purple
let s:hue_4 = '98c379' " green
let s:hue_1 = ['#56b6c2', '73'] " cyan
let s:hue_2 = ['#61afef', '75'] " blue
let s:hue_3 = ['#c678dd', '176'] " purple
let s:hue_4 = ['#98c379', '114'] " green

let s:hue_5 = 'e06c75' " red 1
let s:hue_5_2 = 'be5046' " red 2
let s:hue_5 = ['#e06c75', '168'] " red 1
let s:hue_5_2 = ['#be5046', '130'] " red 2

let s:hue_6 = 'd19a66' " orange 1
let s:hue_6_2 = 'e5c07b' " orange 2
let s:hue_6 = ['#d19a66', '173'] " orange 1
let s:hue_6_2 = ['#e5c07b', '180'] " orange 2

let s:syntax_bg = '282c34'
let s:syntax_gutter = '636d83'
let s:syntax_cursor = '2c323c'
let s:syntax_bg = ['#282c34', '16']
let s:syntax_gutter = ['#636d83', '60']
let s:syntax_cursor = ['#2c323c', '16']

let s:syntax_accent = '528bff'
let s:syntax_accent = ['#528bff', '69']

let s:vertsplit = '181a1f'
let s:special_grey = '3b4048'
let s:visual_grey = '3e4452'
let s:pmenu = '333841'
let s:vertsplit = ['#181a1f', '233']
let s:special_grey = ['#3b4048', '16']
let s:visual_grey = ['#3e4452', '17']
let s:pmenu = ['#333841', '16']
else
let s:mono_1 = '494b53'
let s:mono_2 = '696c77'
let s:mono_3 = 'a0a1a7'
let s:mono_4 = 'c2c2c3'
let s:mono_1 = ['#494b53', '23']
let s:mono_2 = ['#696c77', '60']
let s:mono_3 = ['#a0a1a7', '145']
let s:mono_4 = ['#c2c2c3', '250']

let s:hue_1 = '0184bc' " cyan
let s:hue_2 = '4078f2' " blue
let s:hue_3 = 'a626a4' " purple
let s:hue_4 = '50a14f' " green
let s:hue_1 = ['#0184bc', '31'] " cyan
let s:hue_2 = ['#4078f2', '33'] " blue
let s:hue_3 = ['#a626a4', '127'] " purple
let s:hue_4 = ['#50a14f', '71'] " green

let s:hue_5 = 'e45649' " red 1
let s:hue_5_2 = 'ca1243' " red 2
let s:hue_5 = ['#e45649', '166'] " red 1
let s:hue_5_2 = ['#ca1243', '160'] " red 2

let s:hue_6 = '986801' " orange 1
let s:hue_6_2 = 'c18401' " orange 2
let s:hue_6 = ['#986801', '94'] " orange 1
let s:hue_6_2 = ['#c18401', '136'] " orange 2

let s:syntax_bg = 'fafafa'
let s:syntax_gutter = '9e9e9e'
let s:syntax_cursor = 'f0f0f0'
let s:syntax_bg = ['#fafafa', '255']
let s:syntax_gutter = ['#9e9e9e', '247']
let s:syntax_cursor = ['#f0f0f0', '254']

let s:syntax_accent = '526fff'
let s:syntax_accent_2 = '0083be'
let s:syntax_accent = ['#526fff', '63']
let s:syntax_accent_2 = ['#0083be', '31']

let s:vertsplit = 'e7e9e1'
let s:special_grey = 'd3d3d3'
let s:visual_grey = 'd0d0d0'
let s:pmenu = 'dfdfdf'
let s:vertsplit = ['#e7e9e1', '188']
let s:special_grey = ['#d3d3d3', '251']
let s:visual_grey = ['#d0d0d0', '251']
let s:pmenu = ['#dfdfdf', '253']
endif

let s:syntax_fg = s:mono_1
let s:syntax_fold_bg = s:mono_3

"}}}
" }}}

" Vim editor color --------------------------------------------------------{{{
call <sid>X('Normal', s:syntax_fg, s:syntax_bg, '')
Expand All @@ -343,7 +371,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
call <sid>X('LineNr', s:mono_4, '', '')
call <sid>X('CursorLineNr', s:syntax_fg, s:syntax_cursor, 'none')
call <sid>X('MatchParen', s:hue_5, s:syntax_cursor, 'underline,bold')
call <sid>X('Italic', '', '', 'italic')
call <sid>X('Italic', '', '', s:italic)
call <sid>X('ModeMsg', s:syntax_fg, '', '')
call <sid>X('MoreMsg', s:syntax_fg, '', '')
call <sid>X('NonText', s:mono_3, '', 'none')
Expand Down Expand Up @@ -378,7 +406,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
" }}}

" Standard syntax highlighting --------------------------------------------{{{
call <sid>X('Comment', s:mono_3, '', 'italic')
call <sid>X('Comment', s:mono_3, '', s:italic)
call <sid>X('Constant', s:hue_4, '', '')
call <sid>X('String', s:hue_4, '', '')
call <sid>X('Character', s:hue_4, '', '')
Expand Down Expand Up @@ -577,8 +605,6 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
call <sid>X('haskellString', s:hue_1, '', '')
"}}}



" HTML highlighting -------------------------------------------------------{{{
call <sid>X('htmlArg', s:hue_6, '', '')
call <sid>X('htmlTagName', s:hue_5, '', '')
Expand All @@ -587,7 +613,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
call <sid>X('htmlTag', s:mono_2, '', '')
call <sid>X('htmlEndTag', s:mono_2, '', '')

call <sid>X('MatchTag', s:hue_5, s:syntax_cursor, 'underline,bold')
call <sid>X('MatchTag', s:hue_5, s:syntax_cursor, 'underline,bold')
" }}}

" JavaScript highlighting -------------------------------------------------{{{
Expand Down Expand Up @@ -694,7 +720,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
" Pug (Formerly Jade) highlighting ----------------------------------------{{{
call <sid>X('pugAttributesDelimiter', s:hue_6, '', '')
call <sid>X('pugClass', s:hue_6, '', '')
call <sid>X('pugDocType', s:mono_3, '', 'italic')
call <sid>X('pugDocType', s:mono_3, '', s:italic)
call <sid>X('pugTag', s:hue_5, '', '')
" }}}

Expand All @@ -714,7 +740,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
call <sid>X('pythonStatement', s:hue_3, '', '')
call <sid>X('pythonParam', s:hue_6, '', '')
call <sid>X('pythonEscape', s:hue_5, '', '')
call <sid>X('pythonSelf', s:mono_2, '', 'italic')
call <sid>X('pythonSelf', s:mono_2, '', s:italic)
call <sid>X('pythonClass', s:hue_2, '', '')
call <sid>X('pythonOperator', s:hue_3, '', '')
call <sid>X('pythonEscape', s:hue_5, '', '')
Expand Down Expand Up @@ -764,7 +790,7 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
call <sid>X('vimFunction', s:hue_1, '', '')
call <sid>X('vimFuncName', s:hue_3, '', '')
call <sid>X('vimHighlight', s:hue_2, '', '')
call <sid>X('vimLineComment', s:mono_3, '', 'italic')
call <sid>X('vimLineComment', s:mono_3, '', s:italic)
call <sid>X('vimParenSep', s:mono_2, '', '')
call <sid>X('vimSep', s:mono_2, '', '')
call <sid>X('vimUserFunc', s:hue_1, '', '')
Expand Down Expand Up @@ -808,32 +834,33 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
call <sid>X('manFooter', s:mono_3, '', '')
" }}}

" Neovim Terminal Colors --------------------------------------------------{{{
let g:terminal_color_0 = "#353a44"
let g:terminal_color_8 = "#353a44"
let g:terminal_color_1 = "#e88388"
let g:terminal_color_9 = "#e88388"
let g:terminal_color_2 = "#a7cc8c"
let g:terminal_color_10 = "#a7cc8c"
let g:terminal_color_3 = "#ebca8d"
let g:terminal_color_11 = "#ebca8d"
let g:terminal_color_4 = "#72bef2"
let g:terminal_color_12 = "#72bef2"
let g:terminal_color_5 = "#d291e4"
let g:terminal_color_13 = "#d291e4"
let g:terminal_color_6 = "#65c2cd"
let g:terminal_color_14 = "#65c2cd"
let g:terminal_color_7 = "#e3e5e9"
let g:terminal_color_15 = "#e3e5e9"
"}}}

" ALE (Asynchronous Lint Engine) highlighting -----------------------------{{{
call <sid>X('ALEWarningSign', s:hue_6_2, '', '')
call <sid>X('ALEErrorSign', s:hue_5, '', '')
" }}}

" Neovim Terminal Colors --------------------------------------------------{{{
if has('nvim')
let g:terminal_color_0 = "#353a44"
let g:terminal_color_8 = "#353a44"
let g:terminal_color_1 = "#e88388"
let g:terminal_color_9 = "#e88388"
let g:terminal_color_2 = "#a7cc8c"
let g:terminal_color_10 = "#a7cc8c"
let g:terminal_color_3 = "#ebca8d"
let g:terminal_color_11 = "#ebca8d"
let g:terminal_color_4 = "#72bef2"
let g:terminal_color_12 = "#72bef2"
let g:terminal_color_5 = "#d291e4"
let g:terminal_color_13 = "#d291e4"
let g:terminal_color_6 = "#65c2cd"
let g:terminal_color_14 = "#65c2cd"
let g:terminal_color_7 = "#e3e5e9"
let g:terminal_color_15 = "#e3e5e9"
endif

" Delete functions =========================================================={{{
" delf <SID>X
" delf <SID>XAPI
" delf <SID>rgb
" delf <SID>color
" delf <SID>rgb_color
Expand All @@ -842,18 +869,19 @@ if has('gui_running') || has('termguicolors') || &t_Co == 88 || &t_Co == 256
" delf <SID>grey_color
" delf <SID>grey_level
" delf <SID>grey_number
"}}}
" }}}

endif
"}}}

" Public API --------------------------------------------------------------{{{
function! one#highlight(group, fg, bg, attr)
call <sid>X(a:group, a:fg, a:bg, a:attr)
call <sid>XAPI(a:group, a:fg, a:bg, a:attr)
endfunction
"}}}

if exists('s:dark') && s:dark
set background=dark
endif

" vim: set fdl=0 fdm=marker:
" vim: set fdl=0 fdm=marker: