X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.vimrc;h=05646ee25848d35b5a5c92bb3fd8e3f0332600ce;hb=5e05beac7356065403067ae1084de680153f6eb9;hp=a4e0298645932246cd14632a8a2c3613076cad57;hpb=2f555739f708bc6965fa69175c4a21b54792eadc;p=profile.git diff --git a/.vimrc b/.vimrc index a4e0298..05646ee 100644 --- a/.vimrc +++ b/.vimrc @@ -58,6 +58,9 @@ se smartcase " Look for ctags in home directory first. se tags=~/.tags,./tags,tags +" Don't timeout waiting to interpet, eg, OA as an escape code. +se ttimeoutlen=100 + " Use - and = to create underlines. map - yyp:s/./-/g:let @/='': map = yyp:s/./=/g:let @/='': @@ -68,6 +71,11 @@ map = yyp:s/./=/g:let @/='': if version >= "500" version 5.0 +" Tell Vim we use dark backgrounds in our terminals. +if ! has("gui_running") + se bg=dark +endif + " Vim 5 hardcodes the size of numbers column to 8. let numberwidth=8 @@ -93,6 +101,10 @@ se hlsearch " Syntax highlighting. syn on +" Use a discernably different colour to highlight the cursor which shows +" matching brackets. Our regular cursor is green so use blue instead of cyan. +hi MatchParen ctermbg=blue + " Catch typos. command! W :w command! Wq :wq @@ -109,6 +121,10 @@ fun! Iain_Vars() if ! exists("b:iainverbose") let b:iainverbose = 0 endif + if ! exists("b:iainstatus") + " Window Flags: (F)ocused, (I)nsert mode, Cursor (H)old. + let b:iainstatus = "Fih" + endif endfun " Helper for status line. @@ -238,11 +254,11 @@ syn enable " Nice GUI colour. if has("gui_running") - se guifont=Bitstream\ Vera\ Sans\ Mono\ 10 + se guifont=DejaVu\ Sans\ Mono\ 10 colo darkblue endif if has("win32") - se guifont=Bitstream_Vera_Sans_Mono:h10:cANSI + se guifont=DejaVu_Sans_Mono:h10:cANSI endif " Ignore whitespace when diffing. @@ -341,8 +357,58 @@ if version >= "700" version 7.0 " Change status bar colour when entering insert mode. -au InsertEnter * highlight StatusLine guifg=white guibg=darkred ctermbg=white ctermfg=darkred -au InsertLeave * highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue +fun! Highlight_StatusLine(flag) + " Get current status. + call Iain_Vars() + + " Change the status based on the flag. XXX: Does Vim let us to do flags? + let re = "[" . tolower(a:flag) . toupper(a:flag) . "]" + let b:iainstatus = substitute(b:iainstatus, re, a:flag, "") + + " Default colour. + let s:colour = "darkblue" + let s:termcolour = "" + let s:term88colour = "17" + let s:term256colour = "17" + " Maybe override depending on status. + if b:iainstatus =~# "H" + if b:iainstatus =~# "I" + " Held in insert mode. Add extra highlight if we don't have focus. + if b:iainstatus =~# "f" + let s:colour = "darkmagenta" + else + let s:colour = "darkred" + endif + let s:term88colour = "32" + let s:term256colour = "88" + endif + else + if b:iainstatus =~# "I" + " Regular insert mode. + let s:colour = "darkred" + let s:term88colour = "32" + let s:term256colour = "88" + endif + endif + + if &t_Co == 88 + let s:termcolour = s:term88colour + elseif &t_Co == 256 + let s:termcolour = s:term256colour + else + let s:termcolour = s:colour + endif + + exec "highlight StatusLine guifg=white guibg=" . s:colour . " ctermbg=white ctermfg=" . s:termcolour +endfun + +au CursorHoldI * call Highlight_StatusLine("H") +au CursorMovedI * call Highlight_StatusLine("h") +au FocusGained * call Highlight_StatusLine("F") +au FocusLost * call Highlight_StatusLine("f") +au InsertEnter * call Highlight_StatusLine("I") +au InsertLeave * call Highlight_StatusLine("i") +call Highlight_StatusLine("") " Make diffs vertical by default. se diffopt+=vertical