From a444a2977d10626b30b822d5b4812d305c9bad22 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 12 Aug 2008 13:24:29 +0000 Subject: [PATCH] Version tidying up. Enable wildmenu and ignore object files. Use personal colourscheme if the terminal supports it. git-svn-id: https://svn.cambridge.iain.cx/profile/trunk@132 6be0d1a5-5cfe-0310-89b6-964be062b18b --- .vim/colors/iain.vim | 149 ++++++++++++++++++++++++++++----------------------- .vimrc | 43 +++++++++------ 2 files changed, 110 insertions(+), 82 deletions(-) diff --git a/.vim/colors/iain.vim b/.vim/colors/iain.vim index e23c8dd..f3111cf 100644 --- a/.vim/colors/iain.vim +++ b/.vim/colors/iain.vim @@ -14,7 +14,7 @@ let g:colors_name="iain" if has("gui_running") || &t_Co == 88 || &t_Co == 256 " functions {{{ " returns an approximate grey index for the given grey level - fun grey_number(x) + fun! grey_number(x) if &t_Co == 88 if a:x < 23 return 0 @@ -53,7 +53,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns the actual grey level represented by the grey index - fun grey_level(n) + fun! grey_level(n) if &t_Co == 88 if a:n == 0 return 0 @@ -86,7 +86,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns the palette index for the given grey index - fun grey_color(n) + fun! grey_color(n) if &t_Co == 88 if a:n == 0 return 16 @@ -107,7 +107,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns an approximate color index for the given color level - fun rgb_number(x) + fun! rgb_number(x) if &t_Co == 88 if a:x < 69 return 0 @@ -134,7 +134,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns the actual color level for the given color index - fun rgb_level(n) + fun! rgb_level(n) if &t_Co == 88 if a:n == 0 return 0 @@ -155,7 +155,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns the palette index for the given R/G/B color indices - fun rgb_color(x, y, z) + fun! rgb_color(x, y, z) if &t_Co == 88 return 16 + (a:x * 16) + (a:y * 4) + a:z else @@ -164,7 +164,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns the palette index to approximate the given R/G/B color levels - fun color(r, g, b) + fun! color(r, g, b) " get the closest grey let l:gx = grey_number(a:r) let l:gy = grey_number(a:g) @@ -199,7 +199,7 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " returns the palette index to approximate the 'rrggbb' hex string - fun rgb(rgb) + 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 @@ -208,81 +208,98 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 endfun " sets the highlighting for the given group - fun X(group, fg, bg, attr) + fun! X(group, fg, bg, attr) if a:fg != "" - exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . rgb(a:fg) + if a:fg =~ '^#' + let l:fg = rgb(substitute(a:fg, '^#', '', '')) + else + let l:fg=a:fg + endif + exec "hi " . a:group . " guifg=" . a:fg . " ctermfg=" . l:fg endif if a:bg != "" - exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . rgb(a:bg) + if a:bg =~ '^#' + let l:bg = rgb(substitute(a:bg, '^#', '', '')) + else + let l:bg=a:bg + endif + exec "hi " . a:group . " guibg=" . a:bg . " ctermbg=" . l:bg endif if a:attr != "" exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr endif endfun " }}} - call X("ErrorMsg", "ffffff", "287eff", "") - call X("Visual", "ffffff", "8080ff", "") - call X("VisualNOS", "", "8080ff", "underline") - call X("Todo", "d14a14", "1248d1", "") - call X("Search", "90fff0", "2050d0", "") - call X("IncSearch", "b0ffff", "2050d0", "") - call X("SpecialKey", "00ffff", "", "") - call X("Directory", "00ffff", "", "") - call X("Title", "ff00ff", "", "none") - call X("WarningMsg", "ff0000", "", "") - call X("WildMenu", "ffff00", "000000", "") - call X("ModeMsg", "22cce2", "", "") - call X("Question", "00ff00", "", "none") - call X("NonText", "0030ff", "", "") - call X("VertSplit", "000000", "a9a9a9", "none") - call X("Folded", "808080", "000040", "") - call X("FoldColumn", "808080", "000040", "") - call X("LineNr", "90f020", "", "") - call X("DiffAdd", "00008b", "", "") - call X("DiffChange", "8b008b", "", "") - call X("DiffDelete", "0000ff", "008b8b", "bold") - call X("DiffText", "", "ff0000", "bold") - call X("Cursor", "000000", "ffff00", "") - call X("lCursor", "000000", "ffffff", "") - call X("Comment", "80a0ff", "", "") - "call X("Constant", "ffa0a0", "", "") - "call X("Special", "ffa500", "", "") - "call X("Identifier", "40ffff", "", "") - "call X("Statement", "ffff60", "", "none") - "call X("PreProc", "ff80ff", "", "none") - "call X("Type", "60ff60", "", "none") - call X("Ignore", "ffffff", "", "") + " From darkblue. + call X("ErrorMsg", "#ffffff", "#287eff", "") + call X("Visual", "#ffffff", "#8080ff", "") + call X("VisualNOS", "", "#8080ff", "underline") + "call X("Todo", "#d14a14", "#1248d1", "") + call X("Search", "#ffffff", "#2050d0", "") + call X("IncSearch", "#b0ffff", "#2050d0", "") + "call X("SpecialKey", "#00ffff", "", "") + call X("Directory", "#00ffff", "", "") + call X("Title", "#ff00ff", "", "none") + call X("WarningMsg", "#ff0000", "", "") + "call X("WildMenu", "#ffff00", "#000000", "") + call X("ModeMsg", "#22cce2", "", "") + call X("Question", "#00ff00", "", "none") + call X("NonText", "#0030ff", "", "") + call X("VertSplit", "#000000", "#a9a9a9", "none") + call X("Folded", "#808080", "#000040", "") + call X("FoldColumn", "#808080", "#000040", "") + call X("LineNr", "#90f020", "", "") + call X("DiffAdd", "#00008b", "", "") + call X("DiffChange", "#8b008b", "", "") + call X("DiffDelete", "#0000ff", "#008b8b", "bold") + call X("DiffText", "", "#ff0000", "bold") + call X("Cursor", "#000000", "#ffff00", "") + call X("lCursor", "#000000", "#ffffff", "") + "call X("Comment", "#80a0ff", "", "") + "call X("Constant", "#ffa0a0", "", "") + "call X("Special", "#ffa500", "", "") + "call X("Identifier", "#40ffff", "", "") + "call X("Statement", "#ffff60", "", "none") + "call X("PreProc", "#ff80ff", "", "none") + "call X("Type", "#60ff60", "", "none") + call X("Ignore", "#ffffff", "", "") + + " My stuff. + call X("WildMenu", "blue", "white", "bold") + call X("Todo", "black", "green", "bold") + call X("MoreMsg", "#00ff00", "", "none") - hi Repeat ctermfg=yellow cterm=none - call X("Label", "90f020", "", "none") - call X("Conditional", "ffff60", "", "none") - call X("Statement", "ffff00", "", "none") + call X("Repeat", "yellow", "", "none") + call X("Label", "#90f020", "", "none") + call X("Conditional", "#ffff60", "", "none") + call X("Operator", "#e0e000", "", "none") + call X("Statement", "#ffff00", "", "none") - hi Comment ctermfg=cyan cterm=none + hi Comment ctermfg=lightblue cterm=none guifg=#80a0ff gui=none - hi Function ctermfg=darkgreen cterm=none - call X("Identifier", "40ffff", "", "none") + call X("Function", "darkgreen", "", "none") + call X("Identifier", "#40ffff", "", "none") - hi Character ctermfg=darkmagenta cterm=none - hi String ctermfg=darkmagenta cterm=bold - hi Float ctermfg=magenta cterm=bold - hi Number ctermfg=magenta cterm=none - hi Boolean ctermfg=darkred cterm=bold - call X("Constant", "ffa500", "", "none") + hi Character ctermfg=darkmagenta cterm=bold guifg=magenta gui=bold + hi String ctermfg=darkmagenta cterm=none guifg=magenta gui=none + call X("Float", "magenta", "", "none") + call X("Number", "magenta", "", "bold") + call X("Boolean", "darkred", "", "bold") + call X("Constant", "darkmagenta", "", "bold") - hi SpecialChar ctermfg=green cterm=none - call X("Special", "ff0000", "", "none") + call X("SpecialChar", "#ff0000", "", "none") + call X("Special", "#ff0000", "", "none") - hi Include ctermfg=red cterm=none - hi Macro ctermfg=red cterm=none - hi PreCondit ctermfg=darkred cterm=none - hi PreProc ctermfg=darkred cterm=bold + call X("Include", "red", "", "none") + call X("Macro", "red", "", "none") + call X("PreCondit", "darkred", "", "none") + call X("PreProc", "darkred", "", "bold") - hi StorageClass ctermfg=green cterm=none - hi Structure ctermfg=darkgreen cterm=bold - hi Type ctermfg=darkgreen cterm=none + hi StorageClass ctermfg=green cterm=none guifg=lightgreen gui=none + hi Structure ctermfg=darkgreen cterm=bold guifg=green gui=bold + hi Type ctermfg=darkgreen cterm=none guifg=green gui=none - " Fix up shell stuff. + " Fix up shell stuff. XXX: Should this go in ~/.vim/after/syntax/sh.vim? hi link shShellVariables Identifier " Fix up Perl stuff. diff --git a/.vimrc b/.vimrc index 24b6530..91fd6c1 100644 --- a/.vimrc +++ b/.vimrc @@ -61,19 +61,6 @@ se tags=~/.tags,./tags,tags " Don't timeout waiting to interpet, eg, OA as an escape code. se ttimeoutlen=100 -" Function to create mappings with either a hardcoded \ or . -fun! Mapping(keysequence,mapping) - if version >= "600" - exec "map \\" . a:keysequence . " " . a:mapping - else - exec "map " . a:keysequence . " " . a:mapping - endif -endfun - -" Use - and = to create underlines. -call Mapping("-", "yyp:s/./-/g:let @/='':") -call Mapping("=", "yyp:s/./=/g:let @/='':") - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Handle options only available in Vim 5 and above. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -85,11 +72,18 @@ if ! has("gui_running") se bg=dark endif +" Enable tab-completion prompting for commands. +se wildmenu +" Don't list object files when globbing files to load. +se wildignore+=*.o,*.obj +" So there's no need to assign them low priority. +se suffixes-=*.o,*.obj + " Vim 5 hardcodes the size of numbers column to 8. let numberwidth=8 " Save sessions in UNIX format with / as file separator. This is -" cross-platoform. +" cross-platform. se ssop+=unix,slash " Nuke any pre-existing autocommands. @@ -107,8 +101,10 @@ se t_WS=[8;%p1%d;%p2%dt " Highlight search results. se hlsearch -" Syntax highlighting. -syn on +" Syntax highlighting. New versions will use syn enable instead. +if version < 600 + syn on +endif " Use a discernably different colour to highlight the cursor which shows " matching brackets. Our regular cursor is green so use blue instead of cyan. @@ -222,6 +218,19 @@ endfun " Show the status line for the first time. call Show_StatusLine() +" Function to create mappings with either a hardcoded \ or . +fun! Mapping(keysequence,mapping) + if version >= "600" + exec "map \\" . a:keysequence . " " . a:mapping + else + exec "map " . a:keysequence . " " . a:mapping + endif +endfun + +" Use - and = to create underlines. +call Mapping("-", "yyp:s/./-/g:let @/='':") +call Mapping("=", "yyp:s/./=/g:let @/='':") + " Change to ts=2 with \2. call Mapping("2", ":se ts=2:") " Change to ts=4 with \4. @@ -268,6 +277,8 @@ syn enable if has("gui_running") se guifont=DejaVu\ Sans\ Mono\ 10 colo darkblue +elseif &t_Co > 16 + colo iain endif if has("win32") se guifont=DejaVu_Sans_Mono:h10:cANSI -- 2.7.4