|
| 1 | +" URL: https://github.com/whatyouhide/vim-hackerman |
| 2 | +" Aurhor: Michele 'Ubik' De Simoni <ubik@ubik.tech> |
| 3 | +" Version: 1.0.0 |
| 4 | +" License: MIT |
| 5 | + |
| 6 | + |
| 7 | +" Bootstrap =================================================================== |
| 8 | + |
| 9 | +hi clear |
| 10 | +if exists('syntax_on') | syntax reset | endif |
| 11 | +set background=dark |
| 12 | +let g:colors_name = 'hackerman' |
| 13 | + |
| 14 | + |
| 15 | +" Helper functions ============================================================= |
| 16 | + |
| 17 | +" Execute the 'highlight' command with a List of arguments. |
| 18 | +function! s:Highlight(args) |
| 19 | + exec 'highlight ' . join(a:args, ' ') |
| 20 | +endfunction |
| 21 | + |
| 22 | +function! s:AddGroundValues(accumulator, ground, color) |
| 23 | + let new_list = a:accumulator |
| 24 | + for [where, value] in items(a:color) |
| 25 | + call add(new_list, where . a:ground . '=' . value) |
| 26 | + endfor |
| 27 | + |
| 28 | + return new_list |
| 29 | +endfunction |
| 30 | + |
| 31 | +function! s:Col(group, fg_name, ...) |
| 32 | + " ... = optional bg_name |
| 33 | + |
| 34 | + let pieces = [a:group] |
| 35 | + |
| 36 | + if a:fg_name !=# '' |
| 37 | + let pieces = s:AddGroundValues(pieces, 'fg', s:colors[a:fg_name]) |
| 38 | + endif |
| 39 | + |
| 40 | + if a:0 > 0 && a:1 !=# '' |
| 41 | + let pieces = s:AddGroundValues(pieces, 'bg', s:colors[a:1]) |
| 42 | + endif |
| 43 | + |
| 44 | + call s:Clear(a:group) |
| 45 | + call s:Highlight(pieces) |
| 46 | +endfunction |
| 47 | + |
| 48 | +function! s:Attr(group, attr) |
| 49 | + let l:attrs = [a:group, 'term=' . a:attr, 'cterm=' . a:attr, 'gui=' . a:attr] |
| 50 | + call s:Highlight(l:attrs) |
| 51 | +endfunction |
| 52 | + |
| 53 | +function! s:Clear(group) |
| 54 | + exec 'highlight clear ' . a:group |
| 55 | +endfunction |
| 56 | + |
| 57 | + |
| 58 | +" Colors ====================================================================== |
| 59 | + |
| 60 | +" Let's store all the colors in a dictionary. |
| 61 | +let s:colors = {} |
| 62 | + |
| 63 | +let s:colors.black = { 'gui': '#080808', 'cterm': 232 } |
| 64 | +let s:colors.white = { 'gui': '#FFFFFF', 'cterm': 15 } |
| 65 | +let s:colors.base7 = { 'gui': '#d3ebe9', 'cterm': 7 } |
| 66 | +let s:colors.cyan = { 'gui': '#00d7ff', 'cterm': 45 } |
| 67 | +let s:colors.purple = { 'gui': '#5f0087', 'cterm': 53 } |
| 68 | +let s:colors.green = { 'gui': '#00d700', 'cterm': 40 } |
| 69 | +let s:colors.red = { 'gui': '#800000', 'cterm': 1 } |
| 70 | +let s:colors.orange = { 'gui': '#ffaa00', 'cterm': 214 } |
| 71 | +let s:colors.yellow = { 'gui': '#ffff00', 'cterm': 226 } |
| 72 | +let s:colors.pink = { 'gui': '#d700af', 'cterm': 201 } |
| 73 | +let s:colors.violet = { 'gui': '#6f00ff', 'cterm': 57 } |
| 74 | +let s:colors.blue = { 'gui': '#133460', 'cterm': 23 } |
| 75 | +let s:colors.gray = { 'gui': '#969896', 'cterm': 246 } |
| 76 | +let s:colors.darkergray = { 'gui': '#1c1c1c', 'cterm': 233 } |
| 77 | +let s:colors.base4 = { 'gui': '#245361', 'cterm': 23 } |
| 78 | +let s:colors.base6 = { 'gui': '#99d1ce', 'cterm': 116 } |
| 79 | + |
| 80 | +" Native highlighting ========================================================== |
| 81 | + |
| 82 | +let s:background = 'black' |
| 83 | + |
| 84 | +" This is the background colour of the line's number |
| 85 | +let s:linenr_background = 'darkergray' |
| 86 | + |
| 87 | +" Everything starts here. |
| 88 | +call s:Col('Normal', 'cyan', s:background) |
| 89 | + |
| 90 | +" Line, cursor and so on. |
| 91 | +call s:Col('Cursor', 'blue', 'base7') |
| 92 | +call s:Col('CursorLine', '', 'darkergray') |
| 93 | +call s:Col('CursorColumn', '', 'black') |
| 94 | + |
| 95 | +" Sign column, line numbers. |
| 96 | +call s:Col('LineNr', 'cyan', s:linenr_background) |
| 97 | +call s:Col('CursorLineNr', 'pink', s:linenr_background) |
| 98 | +call s:Col('SignColumn', '', s:linenr_background) |
| 99 | +call s:Col('ColorColumn', '', s:linenr_background) |
| 100 | + |
| 101 | +" Visual selection. |
| 102 | +call s:Col('Visual', '', 'blue') |
| 103 | + |
| 104 | +" Easy-to-guess code elements. |
| 105 | +call s:Col('Comment', 'gray') |
| 106 | +call s:Col('String', 'green') |
| 107 | +call s:Col('Number', 'orange') |
| 108 | +call s:Col('Statement', 'pink') |
| 109 | +call s:Col('Special', 'orange') |
| 110 | +call s:Col('Identifier', 'pink') |
| 111 | +call s:Col('Constant', 'orange') |
| 112 | + |
| 113 | +" Some HTML tags (<title>, some <h*>s) |
| 114 | +call s:Col('Title', 'pink') |
| 115 | + |
| 116 | +" <a> tags. |
| 117 | +call s:Col('Underlined', 'yellow') |
| 118 | +call s:Attr('Underlined', 'underline') |
| 119 | + |
| 120 | +" Types, HTML attributes. |
| 121 | +call s:Col('Type', 'orange') |
| 122 | + |
| 123 | +" Tildes on the bottom of the page. |
| 124 | +call s:Col('NonText', 'base4') |
| 125 | + |
| 126 | +" Concealed stuff. |
| 127 | +call s:Col('Conceal', 'cyan', s:background) |
| 128 | + |
| 129 | +" TODO and similar tags. |
| 130 | +call s:Col('Todo', 'darkergray', s:background) |
| 131 | + |
| 132 | +" The column separating vertical splits. |
| 133 | +call s:Col('VertSplit', 'pink', s:linenr_background) |
| 134 | +call s:Col('StatusLineNC', 'pink', 'blue') |
| 135 | + |
| 136 | +" Matching parenthesis. |
| 137 | +call s:Col('MatchParen', 'black', 'orange') |
| 138 | + |
| 139 | +" Special keys, e.g. some of the chars in 'listchars'. See ':h listchars'. |
| 140 | +call s:Col('SpecialKey', 'base4') |
| 141 | + |
| 142 | +" Folds. |
| 143 | +call s:Col('Folded', 'base6', 'blue') |
| 144 | +call s:Col('FoldColumn', 'cyan', 'base4') |
| 145 | + |
| 146 | +" Searching. |
| 147 | +call s:Col('Search', 'blue', 'yellow') |
| 148 | +call s:Attr('IncSearch', 'reverse') |
| 149 | + |
| 150 | +" Popup menu. |
| 151 | +call s:Col('Pmenu', 'base6', 'blue') |
| 152 | +call s:Col('PmenuSel', 'base7', 'base4') |
| 153 | +call s:Col('PmenuSbar', '', 'blue') |
| 154 | +call s:Col('PmenuThumb', '', 'base4') |
| 155 | + |
| 156 | +" Command line stuff. |
| 157 | +call s:Col('ErrorMsg', 'red', 'black') |
| 158 | +call s:Col('Error', 'red', 'black') |
| 159 | +call s:Col('ModeMsg', 'blue') |
| 160 | +call s:Col('WarningMsg', 'red') |
| 161 | + |
| 162 | +" Wild menu. |
| 163 | +" StatusLine determines the color of the non-active entries in the wild menu. |
| 164 | +call s:Col('StatusLine', 'cyan', 'blue') |
| 165 | +call s:Col('WildMenu', 'base7', 'cyan') |
| 166 | + |
| 167 | +" The 'Hit ENTER to continue prompt'. |
| 168 | +call s:Col('Question', 'green') |
| 169 | + |
| 170 | +" Tab line. |
| 171 | +call s:Col('TabLineSel', 'base7', 'blue') " the selected tab |
| 172 | +call s:Col('TabLine', 'base6', 'blue') " the non-selected tabs |
| 173 | +call s:Col('TabLineFill', 'black', 'black') " the rest of the tab line |
| 174 | + |
| 175 | +" Spelling. |
| 176 | +call s:Col('SpellBad', 'base7', 'red') |
| 177 | +call s:Col('SpellCap', 'base7', 'blue') |
| 178 | +call s:Col('SpellLocal', 'yellow') |
| 179 | +call s:Col('SpellRare', 'base7', 'violet') |
| 180 | + |
| 181 | +" Diffing. |
| 182 | +call s:Col('DiffAdd', 'base7', 'green') |
| 183 | +call s:Col('DiffChange', 'base7', 'blue') |
| 184 | +call s:Col('DiffDelete', 'base7', 'red') |
| 185 | +call s:Col('DiffText', 'base7', 'cyan') |
| 186 | +call s:Col('DiffAdded', 'green') |
| 187 | +call s:Col('DiffChanged', 'blue') |
| 188 | +call s:Col('DiffRemoved', 'red') |
| 189 | +call s:Col('DiffSubname', 'base4') |
| 190 | + |
| 191 | +" Directories (e.g. netrw). |
| 192 | +call s:Col('Directory', 'cyan') |
| 193 | + |
| 194 | + |
| 195 | +" Programming languages and filetypes ========================================== |
| 196 | + |
| 197 | +" Ruby. |
| 198 | +call s:Col('rubyDefine', 'blue') |
| 199 | +call s:Col('rubyStringDelimiter', 'green') |
| 200 | + |
| 201 | +" HTML (and often Markdown). |
| 202 | +call s:Col('htmlArg', 'blue') |
| 203 | +call s:Col('htmlItalic', 'darkergray') |
| 204 | +call s:Col('htmlBold', 'cyan', '') |
| 205 | + |
| 206 | +" Python. |
| 207 | +call s:Col('pythonAttribute', 'yellow') |
| 208 | +call s:Col('pythonStatement', 'pink') |
| 209 | +call s:Col('pythonInclude', 'red') |
| 210 | +call s:Col('pythonFunction', 'yellow') |
| 211 | +call s:Col('pythonBuiltin', 'blue') |
| 212 | +call s:Col('pythonEscape', 'blue') |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | +" Plugin ======================================================================= |
| 218 | + |
| 219 | +" GitGutter |
| 220 | +call s:Col('GitGutterAdd', 'green', s:linenr_background) |
| 221 | +call s:Col('GitGutterChange', 'cyan', s:linenr_background) |
| 222 | +call s:Col('GitGutterDelete', 'orange', s:linenr_background) |
| 223 | +call s:Col('GitGutterChangeDelete', 'darkergray', s:linenr_background) |
| 224 | + |
| 225 | +" CtrlP |
| 226 | +call s:Col('CtrlPNoEntries', 'base7', 'orange') " no entries |
| 227 | +call s:Col('CtrlPMatch', 'green') " matching part |
| 228 | +call s:Col('CtrlPPrtBase', 'base4') " '>>>' prompt |
| 229 | +call s:Col('CtrlPPrtText', 'cyan') " text in the prompt |
| 230 | +call s:Col('CtrlPPtrCursor', 'base7') " cursor in the prompt |
| 231 | + |
| 232 | +" unite.vim |
| 233 | +call s:Col('UniteGrep', 'base7', 'green') |
| 234 | +let g:unite_source_grep_search_word_highlight = 'UniteGrep' |
| 235 | + |
| 236 | + |
| 237 | +" Cleanup ===================================================================== |
| 238 | + |
| 239 | +unlet s:colors |
| 240 | +unlet s:background |
| 241 | +unlet s:linenr_background |
0 commit comments