diff --git a/.vim/bundle/lusty b/.vim/bundle/lusty index c504654..6118864 160000 --- a/.vim/bundle/lusty +++ b/.vim/bundle/lusty @@ -1 +1 @@ -Subproject commit c504654f37adbeeebc31796eea3ba828429dfb40 +Subproject commit 6118864a4d84521028e8079317f838cef1c32869 diff --git a/.vim/bundle/nerdtree b/.vim/bundle/nerdtree index 40d05ac..9a341ec 160000 --- a/.vim/bundle/nerdtree +++ b/.vim/bundle/nerdtree @@ -1 +1 @@ -Subproject commit 40d05ace57fb51cc2c2b2e9eb81c4832ed291630 +Subproject commit 9a341ec18f631e58398350cc9665b8ec4d50954d diff --git a/.vim/bundle/syntastic b/.vim/bundle/syntastic index 78f345b..51001b6 160000 --- a/.vim/bundle/syntastic +++ b/.vim/bundle/syntastic @@ -1 +1 @@ -Subproject commit 78f345bab3865159596ffeeaaffd580e82716edd +Subproject commit 51001b66de7d9a0a6f20acd843a24fdb82bdaf2c diff --git a/.vim/bundle/vim-gitgutter b/.vim/bundle/vim-gitgutter index 989ad9b..25d428c 160000 --- a/.vim/bundle/vim-gitgutter +++ b/.vim/bundle/vim-gitgutter @@ -1 +1 @@ -Subproject commit 989ad9b0fba141806175248f30c383957bfd89df +Subproject commit 25d428c3900d8f45d2b3f771a734033fb0104262 diff --git a/.vim/filetype.vim b/.vim/filetype.vim index 137f52a..0c19b82 100644 --- a/.vim/filetype.vim +++ b/.vim/filetype.vim @@ -45,24 +45,24 @@ au BufRead,BufNewFile *.go set filetype=go "Settings per filetype -augroup python - "autocmd FileType python set omnifunc=pythoncomplete#Complete - "autocmd FileType python call SuperTabSetCompletionType("") - "autocmd FileType python set completeopt-=preview - autocmd FileType python set ts=4 - autocmd FileType python set softtabstop=4 - autocmd FileType python set shiftwidth=4 - autocmd FileType python set expandtab - autocmd FileType python set nosmartindent - autocmd FileType python let b:auto_trim_whitespace=1 -augroup END -augroup javascript - autocmd FileType javascript set ts=4 - autocmd FileType javascript set softtabstop=4 - autocmd FileType javascript set shiftwidth=4 - autocmd FileType javascript set expandtab - autocmd FileType javascript let b:auto_trim_whitespace=1 -augroup END +"augroup python + ""autocmd FileType python set omnifunc=pythoncomplete#Complete + ""autocmd FileType python call SuperTabSetCompletionType("") + ""autocmd FileType python set completeopt-=preview + "autocmd FileType python set ts=4 + "autocmd FileType python set softtabstop=4 + "autocmd FileType python set shiftwidth=4 + "autocmd FileType python set expandtab + "autocmd FileType python set nosmartindent + "autocmd FileType python let b:auto_trim_whitespace=1 +"augroup END +"augroup javascript + "autocmd FileType javascript set ts=4 + "autocmd FileType javascript set softtabstop=4 + "autocmd FileType javascript set shiftwidth=4 + "autocmd FileType javascript set expandtab + "autocmd FileType javascript let b:auto_trim_whitespace=1 +"augroup END augroup mkd autocmd FileType mkd set ai formatoptions=tcroqn2 comments=n:> @@ -77,4 +77,5 @@ autocmd FileType go let b:auto_trim_whitespace=1 autocmd FileType cpp let b:auto_trim_whitespace=1 autocmd FileType perl let b:auto_trim_whitespace=1 autocmd FileType borg let b:auto_trim_whitespace=1 +autocmd FileType javascript let b:auto_trim_whitespace=1 diff --git a/.vimrc b/.vimrc index 4d57375..7e404e5 100644 --- a/.vimrc +++ b/.vimrc @@ -3,10 +3,10 @@ " | _ \/ _` | '_/ _` | / //(_-< \ V / | ' \| '_/ _| " |___/\__,_|_| \__,_|_\_\ /__/ (_)_/|_|_|_|_|_| \__| " -" Let's have a look. -" First, we are vim, not vi, so start as many others do with " " ** BASIC EDITOR SETTINGS ** +" +" First, we are vim, not vi, so start as many others do with set nocompatible " Set syntax and highlighting @@ -33,6 +33,7 @@ set expandtab let mapleader = "," " Set 'smart' things in Vim +" Search case insensitive, unless it contains Uppercase letters set smartcase " Use all the indent features set autoindent @@ -93,10 +94,14 @@ autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete autocmd FileType python set tags+=$HOME/.vim/tags/python.ctags "autocmd FileType python set omnifunc=pythoncomplete#Complete "autocmd FileType python call SuperTabSetCompletionType("") -" + +" Set filetype for VimOrganizer au! BufRead,BufWrite,BufWritePost,BufNewFile *.org au BufEnter *.org call org#SetOrgFileType() +" Cull trailing whitespace for all files. +autocmd BufWritePre * :call AutoTrimWhitespace() + " Turn on the cursorline (highlight on line under cursor) but only for the " window and buffer you're currently in. A handy trick, I'm trying out as of " 2013-04-12 but the jury is still out. @@ -107,21 +112,25 @@ setlocal cursorline " ** PLUGIN CONFIGURATION ** -" Vim/Unknown +" * Vim general/Unknown let python_highlight_all = 1 let g:Tb_MaxSize=0 let g:Tb_MapCTabSwitchBufs = 1 -" Lusty plugins +" * Configure browser for haskell_doc.vim +let g:haddock_browser = "open" +let g:haddock_browser_callformat = "%s %s" + +" * Lusty plugins let g:LustyExplorerSuppressRubyWarning = 1 let g:LustyJugglerSuppressRubyWarning = 1 let g:LustyJugglerShowKeys = 'a' -" Buftabs +" * Buftabs let g:buftabs_only_basename = 1 "let g:buftabs_in_statusline=1 " -" NERDTree +" * NERDTree let g:NERDChristmasTree = 1 let g:NERDChristmasTree = 1 let g:NERDTreeQuitOnOpen = 1 @@ -129,11 +138,11 @@ let g:NERDTreeWinPos = "right" let g:NERDTreeWinSize = 40 let g:NERDTreeDirArrows=0 -" Tagbar plugin settings +" * Tagbar plugin settings let g:tagbar_width = 40 let g:tagbar_autofocus = 1 -" Taglist plugin settings (deprecated) +" * Taglist plugin settings (deprecated) let Tlist_GainFocus_On_ToggleOpen = 1 let Tlist_Use_Right_Window = 1 let Tlist_Inc_Winwidth = 0 @@ -141,81 +150,30 @@ let Tlist_File_Fold_Auto_Close = 1 let Tlist_WinWidth = 40 let Tlist_Show_One_File = 0 -" ConqueTerm +" * ConqueTerm let g:ConqueTerm_CWInsert = 1 let g:ConqueTerm_InsertOnEnter = 0 let g:ConqueTerm_SendVisKey = 'ss' -"MiniBufExplore Options +" * MiniBufExplorer "let g:miniBufExplMapWindowNavVim = 1 "let g:miniBufExplMapWindowNavArrows = 1 "let g:miniBufExplMapCTabSwitchBufs = 1 "let g:miniBufExplModSelTarget = 1 "let g:miniBufExplForceSyntaxEnable = 1 -" CommandT +" * CommandT let g:CommandTMaxFiles = 1000 let g:CommandTMaxDepth = 7 +" * VimOrganizer +" default Tag list. Will be changed in near future so +" that these are defined by config lines in each .org +" file itself, but now these are where you can change things: +let g:org_todo_setup='TODO | DONE' +" while g:org_tag_setup is itself a string +"let g:org_tag_setup='{@home(h) @work(w) @tennisclub(t)} \n {easy(e) hard(d)} \n {computer(c) phone(p)}' -" ** REMAPPINGS ** -" I used to use tabs, but then I took an arrow to the knee. -" Tabs in vim suck because they aren't what you want. Use tabbar. -"nnoremap gc :tabnew -"nnoremap gK :tabclose -"nnoremap gn gt -"nnoremap gp gT - -" I don't know how I came up with gt for opening the tree, but it stuck. -nmap gt :NERDTreeToggle -nmap gb :TlistToggle -"nnoremap gx :Kwbd -" :Kwbd (defined below) really kills a buffer dead, and closes the window. -" gK is similar. -nnoremap gc :Kwbd -"nnoremap gc :bdelete -nnoremap gK :bdelete! -" I use gn/gp to cycle through open tabs -nnoremap gn :bn -nnoremap gp :bp -nnoremap gz :pclose -" The single most handy way to get around a file. Cursor over a word, and then -" type g* -- you'll go to the next instance of that word in the file. Make it -" easier to reach by calling it gw (go-word) instead of hidden away. -nnoremap gw g* -" Make shift-p like p except, put the line above instead of below. -nmap P op -" Line-based movement is cute, but it's tricky for files with lines that wrap. -" Attune more to what you see on the screen instead of where the lines actually -" are. -nnoremap j gj -nnoremap k gk -xnoremap j gj -xnoremap k gk -nnoremap gj -nnoremap gk -xnoremap gj -xnoremap gk -inoremap gj -inoremap gk -"nnoremap -" Years of using bash and zsh have caused my fingers to expect these Emacs-like -" mappings to exist. Make them exist in vim as well. But eye them with -" suspicion, as they come from Emacs. -nnoremap ^ -nnoremap $ -xnoremap ^ -xnoremap $ -inoremap ^ -inoremap $ - -" Better fold mappings -nnoremap @=(foldlevel('.')?'za':'l') -vnoremap zf -" Just to be handy, Ctrl-C acts like escape. So does jj, which never really -" comes up in practice. If you really need to type jj do so slowly. -imap -inoremap jj " ** STATUSLINE ** @@ -250,10 +208,12 @@ command LoadSession :source ~/.vim_last_session " This is a quick way to edit a persistent scratch buffer for me... command ScratchOpen :e scp://barak@barakmich.com//home/barak/notes/scratch -" Sudo-make-me-a-sandwich write + +" Sudo-make-me-a-sandwich write. For when I forget to be root. command Wdammit :w !sudo tee > /dev/null % -" Doesn't quite work right but can be a real savior if needed +" Doesn't quite work right but can be a real savior if needed. +" Oh-shit-what-was-this-like-before-I-changed-it? function! s:DiffWithSaved() let filetype=&ft diffthis @@ -263,7 +223,16 @@ function! s:DiffWithSaved() endfunction com! DiffSaved call s:DiffWithSaved() -" toggles the quickfix window. +" Highlight lines that are longer than textwidth for the filetype, commonly 80 +" characters. +function! HighlightTooLongLines() + highlight def link RightMargin Error + if &textwidth != 0 + exec 'match RightMargin /\%<' . (&textwidth + 3) . 'v.\%>' . (&textwidth + 1) . 'v/' + endif +endfunction + +" Toggles the quickfix window split. command -bang -nargs=? QFix call QFixToggle(0) function! QFixToggle(forced) if exists("g:qfix_win") && a:forced == 0 @@ -273,7 +242,8 @@ function! QFixToggle(forced) endif endfunction -" used to track the quickfix window +" Make the Quickfix window respond well to commands (for instance, q to close, +" Enter to select, etc). In tandem with the above. augroup QFixToggle autocmd! autocmd BufWinEnter quickfix let g:qfix_win = bufnr("$") @@ -281,33 +251,8 @@ augroup QFixToggle autocmd BufWinLeave * if exists("g:qfix_win") && expand("") == g:qfix_win | unlet! g:qfix_win | endif augroup END -nnoremap ff :QFix -nnoremap fn :cnext -nnoremap fp :cprev -nnoremap aw :exe 'Ack ' . expand('') -nnoremap ac :Ack -nnoremap hh :A -nnoremap o :CommandTBuffer -nnoremap j -nnoremap p :PTW - -function! HighlightTooLongLines() - highlight def link RightMargin Error - if &textwidth != 0 - exec 'match RightMargin /\%<' . (&textwidth + 3) . 'v.\%>' . (&textwidth + 1) . 'v/' - endif -endfunction - -let s:extrarc = expand($HOME . '/.vimrc_google') -if filereadable(s:extrarc) - exec ':so ' . s:extrarc -endif - -" Configure browser for haskell_doc.vim -let g:haddock_browser = "open" -let g:haddock_browser_callformat = "%s %s" - -" new shell execute that pipes output to window +" Execute a command that pipes output to window. Captures output into a new, +" appropriately titled, buffer. function! s:ExecuteInShellOutput(command) let command = join(map(split(a:command), 'expand(v:val)')) let winnr = bufwinnr('^' . command . '$') @@ -322,6 +267,8 @@ function! s:ExecuteInShellOutput(command) silent! execute 'nnoremap r :call ExecuteInShell(''' . command . ''')' echo 'Execution of ' . command . ' complete.' endfunction + +" Same as above, doesn't capture output function! s:ExecuteInShell(command) let command = join(map(split(a:command), 'expand(v:val)')) silent! execute 'silent !'. command @@ -368,13 +315,95 @@ function AutoTrimWhitespace() endif endfunction -autocmd BufWritePre * :call AutoTrimWhitespace() +" ** KEY REMAPPINGS ** +" +" I used to use tabs, but then I took an arrow to the knee. +" Tabs in vim suck because they aren't what you want. Use tabbar. +"nnoremap gc :tabnew +"nnoremap gK :tabclose +"nnoremap gn gt +"nnoremap gp gT +" I don't know how I came up with gt for opening the tree, but it stuck. +nmap gt :NERDTreeToggle +" The same for the TagList, useful for large C files. +nmap gb :TlistToggle +"nnoremap gx :Kwbd +" :Kwbd (defined below) really kills a buffer dead, and closes the window. +" gK is similar. +nnoremap gc :Kwbd +"nnoremap gc :bdelete +nnoremap gK :bdelete! -" default Tag list. Will be changed in near future so -" that these are defined by config lines in each .org -" file itself, but now these are where you can change things: -let g:org_todo_setup='TODO | DONE' -" while g:org_tag_setup is itself a string -"let g:org_tag_setup='{@home(h) @work(w) @tennisclub(t)} \n {easy(e) hard(d)} \n {computer(c) phone(p)}' +" I use gn/gp to cycle through open tabs/buffers +nnoremap gn :bn +nnoremap gp :bp +nnoremap gz :pclose +" The single most handy way to get around a file. Cursor over a word, and then +" type g* -- you'll go to the next instance of that word in the file. Make it +" easier to reach by calling it gw (go-word) instead of hidden away. +nnoremap gw g* +" Make shift-p like p except, put the line above instead of below. +nmap P op +" Line-based movement is cute, but it's tricky for files with lines that wrap. +" Attune more to what you see on the screen instead of where the lines actually +" are. +nnoremap j gj +nnoremap k gk +xnoremap j gj +xnoremap k gk +nnoremap gj +nnoremap gk +xnoremap gj +xnoremap gk +inoremap gj +inoremap gk +"nnoremap +" Years of using bash and zsh have caused my fingers to expect these Emacs-like +" mappings to exist. Make them exist in vim as well. But eye them with +" suspicion, as they come from Emacs. +nnoremap ^ +nnoremap $ +xnoremap ^ +xnoremap $ +inoremap ^ +inoremap $ + +" Better fold mappings +nnoremap @=(foldlevel('.')?'za':'l') +vnoremap zf +" Just to be handy, Ctrl-C acts like escape. So does jj, which never really +" comes up in practice. If you really need to type jj do so slowly. +imap +inoremap jj + +" Leader key functions +" See quickfix. +nnoremap ff :QFix +" Next quickfix. +nnoremap fn :cnext +" Prev quickfix. +nnoremap fp :cprev +" Ack (grep) for the word under the cursor. +nnoremap aw :exe 'Ack ' . expand('') +" Ack prompt. +nnoremap ac :Ack +" For C++ -- A is a great plugin which allows you to jump from the c file to the +" header and vice-versa. Mneumonic here is headerheader. +nnoremap hh :A +" CommandT is useful, but if I'm juggling lots of buffers, limit it to another +" one I have open (instead of standard t). +nnoremap o :CommandTBuffer +nnoremap j +nnoremap p :PTW + +" ** EXTRA INCLUDES ** +" +let s:extrarc = expand($HOME . '/.vimrc_google') +if filereadable(s:extrarc) + exec ':so ' . s:extrarc +endif + +" ** SEE ALSO ** +" filetype.vim