" Vim color file " " Name: desertink.vim " Version: 1.2 " Author: Markus Koller " " Note: Only works in GUI and 88/256 color terminals " " This is a version of the default desert colorscheme with a " darker background and more colorful foreground colors. " " It also adds highlighting for folds, diffs, line numbers, " signcolumn, completion menus, and cursor line/column. " The colors are automatically converted for 88/256 color terminals, " adapted from http://www.vim.org/scripts/script.php?script_id=1243 " " You can find the latest version at https://github.com/toupeira/desertink.vim " set background=dark if version > 580 " no guarantees for version 5.8 and below, but this makes it stop " complaining hi clear if exists("syntax_on") syntax reset endif endif let g:colors_name="desertink" if has("gui_running") || &t_Co >= 88 " functions {{{ " returns an approximate grey index for the given grey level 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_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 endfun " returns an approximate color index for the given color 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 color level for the given color 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 color indices fun! 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 endfun " returns the palette index to approximate the given R/G/B color levels fun! color(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 color 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_color(l:gx) else " use the color return rgb_color(l:x, l:y, l:z) endif else " only one possibility return rgb_color(l:x, l:y, l:z) endif endfun " returns the palette index to approximate the 'rrggbb' hex string fun! rgb(rgb) if a:rgb == "ffffff" return 15 endif let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 return color(l:r, l:g, l:b) endfun " sets the highlighting for the given group, add optional fg, bg and attr " values to override the terminal settings if has('gui_running') || (has('termguicolors') && &termguicolors) fun! X(group, fg, bg, attr, ...) if a:fg != "" exec "hi " . a:group . " guifg=#" . a:fg endif if a:bg != "" exec "hi " . a:group . " guibg=#" . a:bg endif if a:attr != "" exec "hi " . a:group . " gui=" . a:attr endif endfun else fun! X(group, fg, bg, attr, ...) let l:ctermfg = (a:0 > 0 && a:1 != "") ? a:1 : rgb(a:fg) let l:ctermbg = (a:0 > 1 && a:2 != "") ? a:2 : rgb(a:bg) let l:ctermattr = (a:0 > 2 && a:3 != "") ? a:3 : a:attr if a:fg != "" exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . l:ctermfg endif if a:bg != "" exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . l:ctermbg endif if a:attr != "" exec "hi " . a:group . " gui=" . a:attr endif if l:ctermattr != "" exec "hi " . a:group . " cterm=" . l:ctermattr endif endfun endif " }}} call X("Normal", "ffffff", "121212", "", "", "233") call X("NonText", "addbe7", "262626", "bold", "", "235") highlight! link TabLineFill Normal " highlight groups "CursorIM "Directory "WildMenu "Menu "Scrollbar "Tooltip call X("Cursor", "708090", "f0e68c", "") " setting a background color for the cursor line can hide " other background colors such as Error and ErrorMsg call X("CursorLine", "", "1a1a1a", "", "", "235", "none") call X("CursorColumn", "", "1a1a1a", "", "", "235") " use only bold for the cursorline to avoid covering the background "highlight clear CursorLine "highlight clear CursorColumn "highlight CursorLine cterm=bold gui=bold "highlight CursorColumn cterm=bold gui=bold call X("ColorColumn", "", "222222", "", "") call X("StatusLine", "262626", "ffffff", "reverse", "", "", "reverse") call X("StatusLineNC", "262626", "808080", "reverse", "") call X("Question", "00ff7f", "", "bold") call X("Error", "ffffff", "913d3b", "bold") call X("ErrorMsg", "ffffff", "913d3b", "bold") call X("ModeMsg", "daa520", "", "") call X("MoreMsg", "00ff7f", "", "bold") call X("Ignore", "666666", "", "") call X("Todo", "f9f747", "d75f00", "bold") call X("SpellBad", "", "913d3b", "") "call X("VertSplit", "c2bfa5", "7f7f7f", "reverse") highlight! link VertSplit LineNr call X("LineNr", "3e3e3e", "080808", "", "239") "call X("CursorLineNr", "aaaaaa", "080808", "", "253") highlight! link CursorLineNr CursorLine call X("Folded", "ffa500", "262626", "bold") call X("FoldColumn", "d2b48c", "121212", "") call X("SignColumn", "", "121212", "", "", "233") call X("Search", "ffffff", "6b8e23", "bold") call X("IncSearch", "ffffff", "3a663a", "bold") call X("SpecialKey", "9acd32", "", "") call X("Title", "cd5c5c", "", "") call X("Visual", "", "005F87", "bold") call X("WarningMsg", "fa8072", "", "") call X("MatchParen", "", "606060", "bold") call X("DiffAdd", "d7ffaf", "5f875f", "") call X("DiffChange", "d7d7ff", "5f5f87", "") call X("DiffDelete", "ff8080", "cc6666", "") call X("DiffText", "5f5f87", "81a2be", "") call X("Pmenu", "eeeeee", "444444", "") call X("PmenuSel", "ffffff", "555555", "bold") call X("PmenuSbar", "", "666666", "") call X("PmenuThumb", "", "606060", "") " syntax highlighting groups call X("Comment", "87ceeb", "", "") call X("Constant", "ff8080", "", "") call X("Identifier", "98fb98", "", "none") call X("Statement", "f0e260", "", "bold") call X("PreProc", "cd5c5c", "", "bold") call X("Type", "91b365", "", "bold") call X("Special", "ffc266", "", "") "Underlined " delete functions {{{ delf X delf rgb delf color delf rgb_color delf rgb_level delf rgb_number delf grey_color delf grey_level delf grey_number " }}} else " basic colorscheme for 16-color terminals highlight Statement ctermfg=Yellow highlight Identifier ctermfg=Green highlight Type ctermfg=DarkGreen highlight Comment ctermfg=Cyan highlight PreProc ctermfg=Blue highlight LineNr ctermfg=DarkGray highlight Special ctermfg=Brown highlight Constant ctermfg=Red highlight Search ctermfg=Black ctermbg=Green highlight IncSearch ctermfg=DarkGray ctermbg=White highlight Visual ctermfg=White ctermbg=Blue highlight Folded cterm=bold,reverse ctermfg=DarkGray ctermbg=Brown highlight Pmenu cterm=reverse ctermfg=DarkGray ctermbg=White highlight PmenuSel ctermfg=Black ctermbg=White highlight PmenuSbar ctermbg=Black highlight PmenuThumb ctermfg=White " use only bold for the cursorline to avoid covering the background highlight clear CursorLine highlight clear CursorColumn highlight CursorLine cterm=bold gui=bold highlight CursorColumn cterm=bold gui=bold endif " vim: set fdl=0 fdm=marker: