From 8afa68c4f6799ec632c5c686855796f1b214d187 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Fri, 2 Jun 2017 08:45:09 -0400 Subject: [PATCH] Tweak colors in custom vim theme --- vim/colors/campo-dark.vim | 8 +- vim/colors/campo-light.vim | 400 +++++++++++++++++++++++++++++++++++++ vimrc | 23 ++- 3 files changed, 426 insertions(+), 5 deletions(-) create mode 100644 vim/colors/campo-light.vim diff --git a/vim/colors/campo-dark.vim b/vim/colors/campo-dark.vim index 5804699..436f03f 100644 --- a/vim/colors/campo-dark.vim +++ b/vim/colors/campo-dark.vim @@ -276,7 +276,6 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 " Standard Highlighting call X("Comment", s:comment, "", "") - call X("Todo", s:red, s:background, "underline") call X("Title", s:comment, "", "") call X("Cursor", "", s:foreground, "") call X("Identifier", s:grey, "", "none") @@ -294,6 +293,13 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 call X("Define", s:purple, "", "none") call X("Include", s:blue, "", "") call X("Number", s:orange, "", "") + + " Custom TODO/NOTE colors + call X("Todo", s:red, s:background, "underline") + call X("Bugs", s:red, s:background, "standout") + call X("Notes","ffffff",s:background,"standout") + call X("Notices","dcd53e",s:background,"bold") + "call X("Ignore", "666666", "", "") " Vim Highlighting diff --git a/vim/colors/campo-light.vim b/vim/colors/campo-light.vim new file mode 100644 index 0000000..2158821 --- /dev/null +++ b/vim/colors/campo-light.vim @@ -0,0 +1,400 @@ +" basic-light -- a simple light vim theme +" +" Maintainer: zcodes +" Version: 1.0 +" +" the theme file original copyed from Tomorrow theme. +" see: https://github.com/chriskempson/vim-tomorrow-theme.git for it. +" +" the colors choose from Google Material Desgin and some from Sublime Text +" LAZY theme. + +" default gui colors +let s:foreground = "263238" +let s:background = "fbfbfb" +let s:selection = "e3fc8d" +let s:line = "d5d5d5" +let s:comment = "7c7c7c" +let s:red = "d62a28" +let s:orange = "ff7800" +let s:yellow = "eab700" +let s:green = "409b1c" +let s:aqua = "00897b" +let s:blue = "3b5bb5" +let s:purple = "673ab7" +let s:window = "cfd8dc" + +set background=light +hi clear +syntax reset + +let g:colors_name = "basic-light" + +if has("gui_running") || &t_Co == 88 || &t_Co == 256 + " 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_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, 0, 2)) + 0 + let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 + let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 + + return colour(l:r, l:g, l:b) + endfun + + " Sets the highlighting for the given group + fun X(group, fg, bg, attr) + if a:fg != "" + exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . rgb(a:fg) + endif + if a:bg != "" + exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . rgb(a:bg) + endif + if a:attr != "" + exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr + endif + endfun + + " Vim Highlighting + call X("Normal", s:foreground, s:background, "") + call X("LineNr", s:comment, "", "none") + call X("NonText", s:foreground, "", "") + call X("SpecialKey", s:blue, "", "") + call X("Search", s:foreground, s:selection, "") + call X("TabLine", s:foreground, s:background, "reverse") + call X("StatusLine", s:window, s:foreground, "reverse") + call X("StatusLineNC", s:window, s:comment, "reverse") + call X("VertSplit", s:window, s:window, "none") + call X("Visual", "", s:selection, "") + call X("Directory", s:blue, "", "") + call X("ModeMsg", s:green, "", "") + call X("MoreMsg", s:green, "", "") + call X("Question", s:green, "", "") + call X("WarningMsg", s:red, "", "") + call X("MatchParen", "", s:selection, "") + call X("Folded", s:comment, s:background, "") + call X("FoldColumn", s:comment, s:background, "") + if version >= 700 + call X("CursorLine", "", s:line, "none") + call X("CursorColumn", "", s:line, "none") + call X("PMenu", s:foreground, s:selection, "none") + call X("PMenuSel", s:foreground, s:selection, "reverse") + call X("SignColumn", "", s:background, "none") + end + if version >= 703 + call X("ColorColumn", "", s:line, "none") + end + + " Standard Highlighting + call X("Comment", s:comment, "", "none") + call X("Title", s:comment, "", "") + call X("Cursor", "", s:foreground, "") + call X("Identifier", s:aqua, "", "none") + call X("Statement", s:foreground, "", "") + call X("Conditional", s:foreground, "", "") + call X("Repeat", s:foreground, "", "") + call X("Structure", s:purple, "", "") + call X("Function", s:blue, "", "") + call X("Constant", s:foreground, "", "") + call X("String", s:green, "", "") + call X("Special", s:foreground, "", "") + call X("PreProc", s:aqua, "", "") + call X("Operator", s:foreground, "", "none") + call X("Type", s:blue, "", "none") + call X("Define", s:purple, "", "none") + call X("Include", s:blue, "", "") + call X("Number", s:orange, "", "") + "call X("Ignore", "666666", "", "") + + " Custom TODO/NOTE colors + call X("Todo", s:red, s:background, "underline") + call X("Bugs", s:red, s:background, "standout") + call X("Notes","666666", "ffffff","bold") + call X("Notices","dcd53e",s:background,"bold") + + + " Vim Highlighting + call X("vimCommand", s:blue, "", "none") + + " C Highlighting + call X("cType", s:blue, "", "") + call X("cStorageClass", s:blue, "", "") + call X("cConditional", s:red, "", "") + call X("cRepeat", s:red, "", "") + + " PHP Highlighting + call X("phpVarSelector", s:aqua, "", "") + call X("phpKeyword", s:blue, "", "") + call X("phpRepeat", s:red, "", "") + call X("phpConditional", s:blue, "", "") + call X("phpStatement", s:blue, "", "") + call X("phpMemberSelector", s:foreground, "", "") + + " Ruby Highlighting + call X("rubySymbol", s:green, "", "") + call X("rubyConstant", s:yellow, "", "") + call X("rubyAttribute", s:blue, "", "") + call X("rubyInclude", s:blue, "", "") + call X("rubyLocalVariableOrMethod", s:orange, "", "") + call X("rubyCurlyBlock", s:orange, "", "") + call X("rubyStringDelimiter", s:green, "", "") + call X("rubyInterpolationDelimiter", s:orange, "", "") + call X("rubyConditional", s:purple, "", "") + call X("rubyRepeat", s:purple, "", "") + + " Python Highlighting + call X("pythonInclude", s:red, "", "") + call X("pythonStatement", s:aqua, "", "") + call X("pythonConditional", s:blue, "", "") + call X("pythonRepeat", s:blue, "", "") + call X("pythonException", s:blue, "", "") + call X("pythonFunction", s:purple, "", "") + call X("pythonSelf", s:comment, "", "") + call X("pythonOperator", s:blue, "", "") + call X("pythonExtraOperator", s:blue, "", "") + call X("pythonClass", s:blue, "", "") + call X("pythonDecorator", s:yellow, "", "") + call X("pythonDocstring", s:comment, "", "") + call X("pythonBuiltinObj", s:red, "", "") + call X("pythonBuiltinType", s:orange, "", "") + call X("pythonNumber", s:orange, "", "") + + + " Go Highlighting + call X("goStatement", s:purple, "", "") + call X("goConditional", s:purple, "", "") + call X("goRepeat", s:purple, "", "") + call X("goException", s:purple, "", "") + call X("goDeclaration", s:blue, "", "") + call X("goConstants", s:yellow, "", "") + call X("goBuiltins", s:orange, "", "") + + " CoffeeScript Highlighting + call X("coffeeKeyword", s:purple, "", "") + call X("coffeeConditional", s:purple, "", "") + + " JavaScript Highlighting + call X("javaScriptBraces", s:foreground, "", "") + call X("javaScriptFunction", s:purple, "", "") + call X("javaScriptConditional", s:purple, "", "") + call X("javaScriptRepeat", s:purple, "", "") + call X("javaScriptNumber", s:orange, "", "") + call X("javaScriptMember", s:orange, "", "") + + " HTML Highlighting + call X("htmlTag", s:blue, "", "") + call X("htmlTagName", s:blue, "", "") + call X("htmlArg", s:aqua, "", "") + call X("htmlScriptTag", s:blue, "", "") + + " Diff Highlighting + call X("diffAdded", "", s:green, "none") + call X("diffRemoved", "", s:red, "none") + call X("diffChanged", "", s:yellow, "none") + call X("DiffAdd", s:window, s:green, "none") + call X("DiffDelete", s:window, s:red, "none") + call X("DiffChange", s:window, s:yellow, "none") + call X("DiffText", s:background, s:yellow, "none") + + call X("GitGutterAdd", s:green, "", "") + call X("GitGutterDelete", s:red, "", "") + call X("GitGutterChange", s:yellow, "", "") + call X("GitGutterChangeDelete", s:orange, "", "") + + " YAML + call X("yamlBlockMappingKey", s:blue, "", "") + + " Delete Functions + delf X + delf rgb + delf colour + delf rgb_colour + delf rgb_level + delf rgb_number + delf grey_colour + delf grey_level + delf grey_number +endif diff --git a/vimrc b/vimrc index 145463e..cf36511 100644 --- a/vimrc +++ b/vimrc @@ -279,7 +279,7 @@ autocmd bufread,bufnewfile *.lisp,*.scm,*.rkt setlocal equalprg=scmindent.rkt """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let s:default_bg = 'dark' let s:dark_theme = 'campo-dark' -let s:light_theme = 'basic-light' +let s:light_theme = 'campo-light' " Switch between light and dark map l :call ChangeBgTheme('light', 0) @@ -347,19 +347,34 @@ set statusline+=%* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " HIGHLIGHT TODO, NOTE, FIXME, etc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" NOTE: These depend on custom color names (Bugs, Notes and Notices) defined +" in the campo color themes. Since most themes won't define these, you can +" use WildMenu as substitution. +" +" FIXME: the custom Bugs, Notes and Notices highlighting for campo-light isn't +" working... + augroup vimrc_bugs au! - au Syntax * syn match MyBugs /\v<(FIXME|BUG|DEPRECATED|OPTIMIZE):/ + au Syntax * syn match MyBugs /\v<(FIXME|BUG|DEPRECATED):/ \ containedin=.*Comment,vimCommentTitle augroup END -hi def link MyBugs Todo +hi def link MyBugs Bugs augroup vimrc_notes au! au Syntax * syn match MyNotes /\v<(IDEA|NOTE|QUESTION|WARNING|IMPORTANT):/ \ containedin=.*Comment,vimCommentTitle augroup END -hi def link MyNotes WildMenu +hi def link MyNotes Notes + +augroup vimrc_notices + au! + au Syntax * syn match MyNotices /\v<(WARNING|IMPORTANT):/ + \ containedin=.*Comment,vimCommentTitle +augroup END +hi def link MyNotices Notices """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " GIT