diff options
author | Teddy Wing | 2014-04-20 15:20:22 -0400 |
---|---|---|
committer | Teddy Wing | 2014-04-20 15:20:22 -0400 |
commit | ebcfa2eded08423e6f0531fc351b6674a4ae24b5 (patch) | |
tree | 3e0db70888fdaff5a435ef92abf8d8bd4029c754 | |
download | dotvim-ebcfa2eded08423e6f0531fc351b6674a4ae24b5.tar.bz2 |
Initial commit: .vimrc form 2014.04.20
.vimrc from today. Will be re-adding my plugins as git submodules.
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | colors/twilight256.vim | 312 | ||||
-rw-r--r-- | vimrc | 348 |
3 files changed, 666 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..486712f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Vim files +.VimballRecord +.netrwhist + +# Custom +projects/ diff --git a/colors/twilight256.vim b/colors/twilight256.vim new file mode 100644 index 0000000..63f3aaa --- /dev/null +++ b/colors/twilight256.vim @@ -0,0 +1,312 @@ +" twilight256 color scheme file +" Maintainer: Neal Milstein - neal dot milstein at gmail dot com +" Last Change: 2011 Feb 1 +" +" This theme copies the colors from the TextMate theme Twilight. +" +" The theme is designed to be used on a black background. I only tested it +" using a 256-color terminal; I do not think it will work on much else (gvim, +" 8-color terminal, etc.). +" +" The functions in this theme that convert hex color codes to the nearest +" xterm-256 color number are from the theme desert2 (desert256), developed by Henry So, Jr. +" +" The colors of this theme are based on the TextMate Twilight theme +" – www.macromates.com +" +" CUSTOM CHANGES: +" 2014.04.14: +" * Manually set "Normal" ctermbg to 235 (or #262626) +" * Set "NonText" and "SpecialKey" to "Comment" colour +" + +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="twilight256" + +if has("gui_running") || &t_Co == 88 || &t_Co == 256 + " functions {{{ + " returns an approximate grey index for the given grey level + fun <SID>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 <SID>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 <SID>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 <SID>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 <SID>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 <SID>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 <SID>color(r, g, b) + " get the closest grey + let l:gx = <SID>grey_number(a:r) + let l:gy = <SID>grey_number(a:g) + let l:gz = <SID>grey_number(a:b) + + " get the closest color + let l:x = <SID>rgb_number(a:r) + let l:y = <SID>rgb_number(a:g) + let l:z = <SID>rgb_number(a:b) + + if l:gx == l:gy && l:gy == l:gz + " there are two possibilities + let l:dgr = <SID>grey_level(l:gx) - a:r + let l:dgg = <SID>grey_level(l:gy) - a:g + let l:dgb = <SID>grey_level(l:gz) - a:b + let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) + let l:dr = <SID>rgb_level(l:gx) - a:r + let l:dg = <SID>rgb_level(l:gy) - a:g + let l:db = <SID>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 <SID>grey_color(l:gx) + else + " use the color + return <SID>rgb_color(l:x, l:y, l:z) + endif + else + " only one possibility + return <SID>rgb_color(l:x, l:y, l:z) + endif + endfun + + " returns the palette index to approximate the 'rrggbb' hex string + fun <SID>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 <SID>color(l:r, l:g, l:b) + endfun + + " sets the highlighting for the given group + fun <SID>X(group, fg, bg, attr) + if a:fg != "" + exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg) + endif + if a:bg != "" + exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg) + endif + if a:attr != "" + exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr + endif + endfun + " }}} + + call <SID>X("Normal", "ffffff", "", "") + + " Added 2014.04.15: Set background colour to #262626 manually because it + " was displaying as white before. -tw + hi Normal ctermbg=235 + + " highlight groups + "call <SID>X("Cursor", "708090", "f0e68c", "") + "CursorIM + "Directory + "DiffAdd + "DiffChange + "DiffDelete + "DiffText + "ErrorMsg + "call <SID>X("VertSplit", "c2bfa5", "7f7f7f", "reverse") + "call <SID>X("Folded", "ffd700", "4d4d4d", "") + "call <SID>X("FoldColumn", "d2b48c", "4d4d4d", "") + "call <SID>X("IncSearch", "708090", "f0e68c", "") + call <SID>X("LineNr", "CCCCCC", "", "") + "call <SID>X("ModeMsg", "D4D4D4", "", "") + "call <SID>X("MoreMsg", "2e8b57", "", "") + "call <SID>X("NonText", "addbe7", "000000", "bold") + "call <SID>X("Question", "00ff7f", "", "") + "call <SID>X("Search", "f5deb3", "cd853f", "") + "call <SID>X("SpecialKey", "9acd32", "", "") + "call <SID>X("StatusLine", "c2bfa5", "000000", "reverse") + "call <SID>X("StatusLineNC", "c2bfa5", "7f7f7f", "reverse") + "call <SID>X("Title", "cd5c5c", "", "") + call <SID>X("Visual", "D3D3D3", "3E3E3E", "reverse") + "VisualNOS + "call <SID>X("WarningMsg", "fa8072", "", "") + "WildMenu + "Menu + "Scrollbar + "Tooltip + + " syntax highlighting groups + call <SID>X("Comment", "828282", "", "") + call <SID>X("NonText", "828282", "", "") + call <SID>X("SpecialKey", "828282", "", "") + call <SID>X("Constant", "CF6A4C", "", "") + call <SID>X("Identifier", "7587A6", "", "none") + call <SID>X("Function", "9B703F", "", "") + call <SID>X("Define", "CDA869", "", "none") + call <SID>X("Statement", "CDA869", "", "") + call <SID>X("String", "8F9D6A", "", "") + call <SID>X("PreProc", "AFC4DB", "", "") + call <SID>X("Type", "F9EE98", "", "") + call <SID>X("Special", "DAEFA3", "", "") + "Underlined + call <SID>X("Ignore", "666666", "", "") + "Error + call <SID>X("Todo", "ff4500", "eeee00", "") + + " delete functions {{{ + delf <SID>X + delf <SID>rgb + delf <SID>color + delf <SID>rgb_color + delf <SID>rgb_level + delf <SID>rgb_number + delf <SID>grey_color + delf <SID>grey_level + delf <SID>grey_number + " }}} +endif + +" vim: set fdl=0 fdm=marker: @@ -0,0 +1,348 @@ +" Teddy Wing +" http://www.teddywing.com +" +" 2010.11.06 +" +" CHANGELOG: +" 2014.04.03: +" * Add Shift-Tab mapping to exit Insert mode +" +" 2014.04.11: +" * Preserve indentation on blank lines +" +" 2014.04.12: +" * Add leader and symbols for showing invisible characters +" (http://vimcasts.org/episodes/show-invisibles/) +" * Remove `set expandtab` +" * Add `set softtabstop=4` +" * Add function from Vimcasts to set tab width +" * Add normal mode mapping to toggle expandtab +" * Add <leader>[ and ] indentation to retain selection when indenting +" * Add `set hidden` +" * Add `set list` +" * Add soft wrap +" * Source .vimrc whenever it has been saved +" +" 2014.04.15: +" * Add pathogen +" * Add twilight256 colour scheme +" * Add NERD Tree +" * Add Command-T +" * Remap Command-T from <leader>t to <leader>d +" * Set switchbuf=usetab,newtab +" * Map Control-h to :update +" +" 2014.04.16: +" * Set NERDTree sort order such that all files & directories are sorted +" alphabetically, instead of directories appearing above files. +" * Set NERDTree default width to 24 columns +" * Map j -> gj and k -> gk for moving on wrapped lines +" * Set noendofline +" * Add project-level indentation settings for Flashnotes +" * Remove <leader>t <nop> mapping because Command-T will not overwrite +" a pre-existing mapping +" * Install TabBar for buffer tabs, add mappings to access tabs using +" <leader> commands +" * Map Shift-Tab to Esc in normal mode in addition to Insert & Visual +" * Install commentary.vim and set comment strings for Ruby, JavaScript, +" SCSS, HTML, Python +" +" 2014.04.17: +" * Remove `set :noendofline` as it wasn't doing what I wanted it to do +" * Add & set PreserveNoEOL plugin to preserve file EOL +" * Move commentary.vim autocmds into an augroup +" * Always show status line +" * Make custom status line +" * Change `vb` setting to unabbreviated form, `visualbell` +" * Change 'set' to 'setlocal' in my autocommands +" +" 2014.04.18: +" * Add mappings for easier buffer switching (leader-j, leader-k, +" leader-bx) +" * Use 'a' instead of 'i' in my Control-h save mapping because we want +" to return to the same cursor position +" * Map <leader>bl to list buffers +" +" 2014.04.19: +" * Set `timeoutlen` to 500 milliseconds +" +" 2014.04.20: +" * Install EasyGrep plugin and add configuration for EasyGrepCommand=1, +" EasyGrepRecursive=1, EasyGrepEveryMatch=1, +" EasyGrepReplaceAllPerFile=1 +" * Set grepprg=ack +" * Add an extra line of spacing between sections and '===' underlines +" below main headings +" * Move project-specific settings into ~/.vim/projects and source all +" files in that directory +" + + +" Pathogen +" ======== +runtime bundle/vim-pathogen/autoload/pathogen.vim +execute pathogen#infect() +call pathogen#helptags() + + + +" Default configuration +" ===================== +set visualbell t_vb= " Turn off error beep + +set autoindent +set tabstop=4 " Use 4-space tabs +set softtabstop=4 " Allow delete to remove indent when expandtab is enabled +set shiftwidth=4 +" set expandtab + +set wrap " Soft wrap +set linebreak " Don't wrap in the middle of words. Only works when nolist is set + +set scrolloff=3 " Scroll offset: always keep 3 lines + +set showmatch " Highlight matching braces etc. +set hlsearch " Highlight searches +set incsearch " Search for text as you enter it + +set ruler " Show cursor position +set number " Show line numbers + +set list " Show invisibles by default + +set hidden " Don't raise errors when switching buffers with unsaved changes + +" Use tabs for buffers +set switchbuf=usetab,newtab + +set timeoutlen=500 " If <leader>bl and <leader>b are both mapped, wait 0.5 + " seconds instead of 1 second to fire <leader>b if no l + " is pressed subsequently + +set grepprg=ack " Use ack instead of grep + +set laststatus=2 " Always show the status line + +" Statusline +set statusline=%f " Path to file +set statusline+=\ " Separator +set statusline+=%y " Filetype +set statusline+=\ " Separator +set statusline+=%m " File modified? flag +set statusline+=%r " Readonly? flag +set statusline+=\ " Separator +set statusline+=-b%n- " Buffer number as -b{buffer #}- +set statusline+=\ " Separator +set statusline+=%= " Switch to right side +set statusline+=%5l " Line number (ensure space for 5 characters) +set statusline+=, " Comma separator +set statusline+=%-8c " Column number (ensure space for 8 characters) +set statusline+=\ " Separator +set statusline+=%4P " Percent through file in window (ensure space for 4 characters) + + + +" Syntax highlighting (base) +" ========================== +syntax on " Syntax highlighting + +hi Comment ctermfg=green guifg=#919191 cterm=none +hi Constant ctermfg=red guifg=#1C4B80 cterm=none +"hi Identifier +hi Statement ctermfg=blue guifg=#696EC0 +hi PreProc ctermfg=brown guifg=#73371C +hi Type ctermfg=cyan guifg=#696EC0 +hi Special ctermfg=red guifg=#696EC0 +hi Normal ctermfg=black guifg=#dddddd guibg=#09192F + +" Invisible character colours +hi NonText guifg=#4a4a59 +hi SpecialKey guifg=#4a4a59 + +set guifont=Monaco\ 10 + + +" Set Twilight theme +colorscheme twilight256 + + + +" Plugins +" ======= + +" Command-T +" Remap Command-T from <leader>t to <leader>d (BBEdit style) +nnoremap <leader>d :CommandT<cr> + + +" NERDTree +" Alphabetical sort ordering +let NERDTreeSortOrder = [] +let NERDTreeWinSize = 24 + +" Toggle NERDTree with leader command +nnoremap <leader>f :NERDTreeToggle<cr> + + +" TabBar +" j/k to switch to previous/next buffer tab +nnoremap <leader>j :Tbbp<cr> +nnoremap <leader>k :Tbbn<cr> + +" Leader+# to switch to a specific buffer tab +nnoremap <leader>1 :TbBfSwitchTo 1<cr>:<bs> +nnoremap <leader>2 :TbBfSwitchTo 2<cr>:<bs> +nnoremap <leader>3 :TbBfSwitchTo 3<cr>:<bs> +nnoremap <leader>4 :TbBfSwitchTo 4<cr>:<bs> +nnoremap <leader>5 :TbBfSwitchTo 5<cr>:<bs> +nnoremap <leader>6 :TbBfSwitchTo 6<cr>:<bs> +nnoremap <leader>7 :TbBfSwitchTo 7<cr>:<bs> +nnoremap <leader>8 :TbBfSwitchTo 8<cr>:<bs> +nnoremap <leader>9 :TbBfSwitchTo 9<cr>:<bs> +nnoremap <leader>0 :TbBfSwitchTo 10<cr>:<bs> + +inoremap <leader>1 :TbBfSwitchTo 1<cr>:<bs>a +inoremap <leader>2 :TbBfSwitchTo 2<cr>:<bs>a +inoremap <leader>3 :TbBfSwitchTo 3<cr>:<bs>a +inoremap <leader>4 :TbBfSwitchTo 4<cr>:<bs>a +inoremap <leader>5 :TbBfSwitchTo 5<cr>:<bs>a +inoremap <leader>6 :TbBfSwitchTo 6<cr>:<bs>a +inoremap <leader>7 :TbBfSwitchTo 7<cr>:<bs>a +inoremap <leader>8 :TbBfSwitchTo 8<cr>:<bs>a +inoremap <leader>9 :TbBfSwitchTo 9<cr>:<bs>a +inoremap <leader>0 :TbBfSwitchTo 10<cr>:<bs>a + + +" commentary.vim +augroup commentaryvim + autocmd! + autocmd FileType ruby setlocal commentstring=#\ %s + autocmd FileType html setlocal commentstring=<!--\ %s\ --> + autocmd FileType javascript setlocal commentstring=//\ %s + autocmd FileType scss setlocal commentstring=//\ %s + autocmd FileType python setlocal commentstring=#\ %s +augroup END + + +" PreserveNoEOL +let g:PreserveNoEOL = 1 + + +" EasyGrep +let g:EasyGrepCommand = 1 " Use grep instead of vimgrep +let g:EasyGrepRecursive = 1 " Recursive search enabled +let g:EasyGrepEveryMatch = 1 " Multiple matches on the same line are distinct +let g:EasyGrepReplaceAllPerFile = 1 + + + +" Mappings +" ======== + +" Shift-Tab to enter normal mode from insert mode +nnoremap <S-Tab> <Esc> +inoremap <S-Tab> <Esc> +vnoremap <S-Tab> <Esc> + +" Control-h to save (Why 'h'? Because it seemed to be a non-important combo +" across modes, and because bash by default doesn't let me map Control-s) +nnoremap <c-h> <esc>:update<cr> +inoremap <c-h> <esc>:update<cr>a +vnoremap <c-h> <esc>:update<cr>v + +" Preserve indentation on empty lines +" http://stackoverflow.com/a/7413117 +inoremap <CR> <CR>x<BS> +nnoremap o ox<BS> +nnoremap O Ox<BS> + +" Show invisibles with <leader>i +nnoremap <leader>i :set list!<cr> + +" Use TextMate-style symbols for tabs and EOLs +set listchars=tab:▸\ ,eol:¬ + +" Toggle between tab and space indentation +nnoremap <leader>st :set expandtab! expandtab?<cr> + +" OS X-style indentation, retains selection when indenting +" http://vimcasts.org/episodes/indentation-commands/ +nnoremap <leader>[ << +nnoremap <leader>] >> +vnoremap <leader>[ <gv +vnoremap <leader>] >gv + +" Allow easy moving to wrapped lines +nnoremap j gj +nnoremap k gk + +" Easier buffer switching +nnoremap <leader>bl :ls<cr> +nnoremap <leader>j :bnext<cr> +nnoremap <leader>k :bprevious<cr> + +" Close buffer without closing split +" http://stackoverflow.com/a/4468491 +nnoremap <leader>bx :bp \| bd #<cr> + + + +" Commands +" ======== + +" Set tabstop, softtabstop and shiftwidth to the same value +" http://vimcasts.org/episodes/tabs-and-spaces/ +command! -nargs=* Stab call Stab() +function! Stab() + let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') + if l:tabstop > 0 + let &l:sts = l:tabstop + let &l:ts = l:tabstop + let &l:sw = l:tabstop + endif + call SummarizeTabs() +endfunction + +function! SummarizeTabs() + try + echohl ModeMsg + echon 'tabstop='.&l:ts + echon ' shiftwidth='.&l:sw + echon ' softtabstop='.&l:sts + if &l:et + echon ' expandtab' + else + echon ' noexpandtab' + endif + finally + echohl None + endtry +endfunction + + +" Swap between soft wrapping and no wrapping +" http://vimcasts.org/episodes/soft-wrapping-text/ +command! -nargs=* Wrap set wrap linebreak nolist + + + +" Autocommands +" ============ + +" Source the vimrc file after saving it +" http://vimcasts.org/episodes/updating-your-vimrc-file-on-the-fly/ +" if has("autocmd") +" autocmd bufwritepost .vimrc source $MYVIMRC +" endif + + + +" Project Settings +" ================ + +" Source all files in the ~/.vim/projects directory +" http://stackoverflow.com/a/4500936 +for f in split(glob('~/.vim/projects/*.vim'), '\n') + execute 'source' f +endfor + |