368 lines
11 KiB
VimL
368 lines
11 KiB
VimL
set nocompatible
|
||
|
||
" Set syntax and highlighting
|
||
syntax on
|
||
"colorscheme slate
|
||
"colorscheme dante
|
||
colorscheme baraknew
|
||
|
||
" Set default spacing
|
||
"set gfn=Monaco:h12:a
|
||
set ts=8
|
||
set softtabstop=2
|
||
set shiftwidth=2
|
||
set expandtab
|
||
let mapleader = ","
|
||
|
||
filetype off
|
||
"call pathogen#runtime_append_all_bundles()
|
||
execute pathogen#infect()
|
||
filetype plugin indent on
|
||
" Set 'smart' things in Vim
|
||
set smartcase
|
||
set autoindent
|
||
set smartindent
|
||
set cindent
|
||
set hidden
|
||
set backspace=indent,eol,start
|
||
|
||
set history=1000
|
||
set wildmenu
|
||
set wildmode=list:longest
|
||
set ruler
|
||
|
||
set splitbelow
|
||
set completeopt=menu,menuone,longest
|
||
" If you prefer the Omni-Completion tip window to close when a selection is
|
||
" made, these lines close it on movement in insert mode or when leaving
|
||
" insert mode
|
||
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
|
||
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
|
||
|
||
" Some stuff for console 256 Colors
|
||
set t_Co=256
|
||
set t_Sf=ESC[3%dm
|
||
set t_Sb=ESC[4%dm
|
||
"set t_kb=
|
||
"
|
||
"if v:version >= 703
|
||
"set relativenumber
|
||
"set colorcolumn=81
|
||
"endif
|
||
|
||
|
||
" Sources
|
||
"source ~/.vim/supertab.vim
|
||
"source ~/.vim/charm.vim
|
||
"source ~/.vim/plugin/AppleT.vim
|
||
runtime macros/matchit.vim
|
||
|
||
" Completion features (TODO: Add to filetype.vim)
|
||
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("<C-X><C-O>")
|
||
let python_highlight_all = 1
|
||
let g:Tb_MaxSize=0
|
||
let g:Tb_MapCTabSwitchBufs = 1
|
||
let g:LustyExplorerSuppressRubyWarning = 1
|
||
let g:LustyJugglerSuppressRubyWarning = 1
|
||
let g:LustyJugglerShowKeys = 'a'
|
||
let g:buftabs_only_basename = 1
|
||
"let g:buftabs_in_statusline=1
|
||
let g:NERDChristmasTree = 1
|
||
let g:NERDChristmasTree = 1
|
||
let g:NERDTreeQuitOnOpen = 1
|
||
let g:NERDTreeWinPos = "right"
|
||
let g:NERDTreeWinSize = 40
|
||
|
||
" Tagbar plugin settings
|
||
let g:tagbar_width = 40
|
||
let g:tagbar_autofocus = 1
|
||
|
||
" Taglist plugin settings (deprecated)
|
||
let Tlist_GainFocus_On_ToggleOpen = 1
|
||
let Tlist_Use_Right_Window = 1
|
||
let Tlist_Inc_Winwidth = 0
|
||
let Tlist_File_Fold_Auto_Close = 1
|
||
let Tlist_WinWidth = 40
|
||
let Tlist_Show_One_File = 0
|
||
|
||
let g:ConqueTerm_CWInsert = 1
|
||
let g:ConqueTerm_InsertOnEnter = 0
|
||
let g:ConqueTerm_SendVisKey = '<Leader>ss'
|
||
|
||
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
|
||
au BufEnter *.org call org#SetOrgFileType()
|
||
"MiniBufExplore Options
|
||
"let g:miniBufExplMapWindowNavVim = 1
|
||
"let g:miniBufExplMapWindowNavArrows = 1
|
||
"let g:miniBufExplMapCTabSwitchBufs = 1
|
||
"let g:miniBufExplModSelTarget = 1
|
||
"let g:miniBufExplForceSyntaxEnable = 1
|
||
|
||
|
||
"Remappings
|
||
"Open in tabs...
|
||
"nnoremap gc :tabnew<CR>
|
||
"nnoremap gK :tabclose<CR>
|
||
"nnoremap gn gt
|
||
"nnoremap gp gT
|
||
nmap gt :NERDTreeToggle<CR>
|
||
nmap gb :TlistToggle<CR>
|
||
"nnoremap gx :Kwbd<CR>
|
||
nnoremap gc :Kwbd<CR>
|
||
"nnoremap gc :bdelete<CR>
|
||
nnoremap gK :bdelete!<CR>
|
||
nnoremap gn :bn<CR>
|
||
nnoremap gp :bp<CR>
|
||
nnoremap gz :pclose<CR>
|
||
nnoremap gw g*
|
||
nmap P o<Esc>p
|
||
nnoremap j gj
|
||
nnoremap k gk
|
||
xnoremap j gj
|
||
xnoremap k gk
|
||
nnoremap <Down> gj
|
||
nnoremap <Up> gk
|
||
xnoremap <Down> gj
|
||
xnoremap <Up> gk
|
||
inoremap <Down> <C-o>gj
|
||
inoremap <Up> <C-o>gk
|
||
"nnoremap <C-i> <C-a>
|
||
nnoremap <C-a> ^
|
||
nnoremap <C-e> $
|
||
xnoremap <C-a> ^
|
||
xnoremap <C-e> $
|
||
inoremap <C-a> <C-O>^
|
||
inoremap <C-e> <C-O>$
|
||
imap <C-c> <Esc>
|
||
|
||
|
||
"nmap <silent> <C-j> :FocusNextWindow<CR>
|
||
"nmap <silent> <C-k> :FocusPrevWindow<CR>
|
||
"nmap <silent> <C-m> :FocusMasterWindow<CR>
|
||
"nmap <silent> <C-Enter> :SwapWithMasterWindow<CR>
|
||
"nmap <silent> <C-Down> :SwapWithNextWindow<CR>
|
||
"nmap <silent> <C-Up> :SwapWithPrevWindow<CR>
|
||
|
||
set laststatus=2
|
||
set statusline=%t "tail of the filename
|
||
"set statusline+=[%{&ff}] "file format
|
||
"set statusline+=%h "help file flag
|
||
set statusline+=\ %w "help file flag
|
||
set statusline+=%r "read only flag
|
||
set statusline+=%y "filetype
|
||
set statusline+=\ %m "modified flag
|
||
set statusline+=%= "left/right separator
|
||
set statusline+=%{fugitive#statusline()}\ \
|
||
set statusline+=%c, "cursor column
|
||
set statusline+=%l/%L "cursor line/total lines
|
||
set statusline+=\ %P "percent through file
|
||
|
||
" Useful functions
|
||
|
||
" Add capital W so I can be lazy about my shift jey
|
||
if !exists(":W")
|
||
command W :w
|
||
endif
|
||
|
||
command Cdf :cd %:p:h
|
||
|
||
" Save a vim session! Useful if you want to save buffer states and so on
|
||
command SaveSession :mksession! ~/.vim_last_session
|
||
command LoadSession :source ~/.vim_last_session
|
||
|
||
let g:CommandTMaxFiles = 1000
|
||
let g:CommandTMaxDepth = 7
|
||
|
||
" 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
|
||
command Wdammit :w !sudo tee > /dev/null %
|
||
|
||
" Doesn't quite work right but can be a real savior if needed
|
||
function! s:DiffWithSaved()
|
||
let filetype=&ft
|
||
diffthis
|
||
vnew | r # | normal! 1Gdd
|
||
diffthis
|
||
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
|
||
endfunction
|
||
com! DiffSaved call s:DiffWithSaved()
|
||
|
||
" Forget where I found this...
|
||
function! Find(name)
|
||
let l:_name = substitute(a:name, "\\s", "*", "g")
|
||
"let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" | perl -ne 'print \"$.\\t$_\"'")
|
||
let l:list=system("find . -path \"*/.svn\" -prune -o -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" -print | perl -ne 'print \"$.\\t$_\"'")
|
||
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
|
||
if l:num < 1
|
||
echo "'".a:name."' not found"
|
||
return
|
||
endif
|
||
if l:num != 1
|
||
echo l:list
|
||
let l:input=input("Which ? (<enter>=nothing)\n")
|
||
if strlen(l:input)==0
|
||
return
|
||
endif
|
||
if strlen(substitute(l:input, "[0-9]", "", "g"))>0
|
||
echo "Not a number"
|
||
return
|
||
endif
|
||
if l:input<1 || l:input>l:num
|
||
echo "Out of range"
|
||
return
|
||
endif
|
||
let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
|
||
else
|
||
let l:line=l:list
|
||
endif
|
||
let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
|
||
execute ":e ".l:line
|
||
endfunction
|
||
command! -nargs=1 Find :call Find("<args>")
|
||
|
||
" toggles the quickfix window.
|
||
command -bang -nargs=? QFix call QFixToggle(<bang>0)
|
||
function! QFixToggle(forced)
|
||
if exists("g:qfix_win") && a:forced == 0
|
||
cclose
|
||
else
|
||
execute "copen " . 15
|
||
endif
|
||
endfunction
|
||
|
||
" used to track the quickfix window
|
||
augroup QFixToggle
|
||
autocmd!
|
||
autocmd BufWinEnter quickfix let g:qfix_win = bufnr("$")
|
||
autocmd BufWinEnter quickfix exec "nnoremap <silent> <buffer> q :QFix<CR>"
|
||
autocmd BufWinLeave * if exists("g:qfix_win") && expand("<abuf>") == g:qfix_win | unlet! g:qfix_win | endif
|
||
augroup END
|
||
|
||
nnoremap <Leader>ff :QFix<CR>
|
||
nnoremap <Leader>fn :cnext<CR>
|
||
nnoremap <Leader>fp :cprev<CR>
|
||
nnoremap <Leader>aw :exe 'Ack ' . expand('<cword>')<CR>
|
||
nnoremap <Leader>ac :Ack
|
||
nnoremap <Leader>hh :A<CR>
|
||
nnoremap <silent> <Leader>o :CommandTBuffer<CR>
|
||
nnoremap <Leader>j <C-^>
|
||
nnoremap <Leader>p :PTW
|
||
|
||
" Googley things....
|
||
|
||
function! HighlightTooLongLines()
|
||
highlight def link RightMargin Error
|
||
if &textwidth != 0
|
||
exec 'match RightMargin /\%<' . (&textwidth + 3) . 'v.\%>' . (&textwidth + 1) . 'v/'
|
||
endif
|
||
endfunction
|
||
|
||
let g:google_enable = 0
|
||
let g:disable_google_optional_settings = 1
|
||
if filereadable("/usr/share/vim/google/google.vim")
|
||
source /usr/share/vim/google/google.vim
|
||
let g:google_enable = 1
|
||
endif
|
||
|
||
if g:google_enable != 0
|
||
augroup filetypedetect
|
||
au WinEnter,BufNewFile,BufRead * call HighlightTooLongLines()
|
||
augroup END
|
||
" Load Blaze errors into quickfix mode
|
||
nmap <Leader>bl :call LoadBlazeErrors():cc<CR>
|
||
" Run the most appropriate blaze command on the target for the current file.
|
||
nmap <Leader>bb :call BlazeDwim()
|
||
" Run update_deps on the target for the current file.
|
||
nmap <Leader>bu :call UpdateDepsDwim()<CR>
|
||
" Configure a 'Comments' command to import CL code review comments into the
|
||
" quickfix buffer.
|
||
command! Comments cexpr system('git5 comments -q -u')
|
||
command! Lint cexpr system('git5 lint -q')
|
||
nmap <leader>bs :!google-chrome https://cs.corp.google.com/'<cword>'<CR><CR>
|
||
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
|
||
function! s:ExecuteInShellOutput(command)
|
||
let command = join(map(split(a:command), 'expand(v:val)'))
|
||
let winnr = bufwinnr('^' . command . '$')
|
||
silent! execute winnr < 0 ? 'botright new ' . fnameescape(command) : winnr . 'wincmd w'
|
||
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile wrap number
|
||
echo 'Executing ' . command . '...'
|
||
silent! execute 'silent %!'. command
|
||
" uncomment this if you want the new buffer to try to grow to accommodate the output
|
||
"silent! execute 'resize ' . line('$')
|
||
silent! redraw
|
||
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
|
||
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>'
|
||
echo 'Execution of ' . command . ' complete.'
|
||
endfunction
|
||
function! s:ExecuteInShell(command)
|
||
let command = join(map(split(a:command), 'expand(v:val)'))
|
||
silent! execute 'silent !'. command
|
||
redraw!
|
||
echo 'Execution of ' . command . ' complete.'
|
||
endfunction
|
||
|
||
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShellOutput(<q-args>)
|
||
command! -complete=shellcmd -nargs=+ Exec call s:ExecuteInShell(<q-args>)
|
||
command! -nargs=* Make call s:ExecuteInShellOutput('make '.<q-args>)
|
||
command! -nargs=* Git call s:ExecuteInShellOutput('git '.<q-args>)
|
||
command! -nargs=* PTW call s:ExecuteInShell('ptw post --client=vim "'.<q-args>.'"')
|
||
|
||
" Highlight all instances of word under cursor, when idle.
|
||
" Useful when studying strange source code.
|
||
" Type z/ to toggle highlighting on/off.
|
||
nnoremap z/ :if AutoHighlightToggle()<Bar>set hls<Bar>else<Bar>set nohls<Bar>endif<CR>
|
||
function! AutoHighlightToggle()
|
||
let @/ = ''
|
||
if exists('#auto_highlight')
|
||
au! auto_highlight
|
||
augroup! auto_highlight
|
||
setl updatetime=4000
|
||
echo 'Highlight current word: off'
|
||
return 0
|
||
else
|
||
augroup auto_highlight
|
||
au!
|
||
au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
|
||
augroup end
|
||
setl updatetime=500
|
||
echo 'Highlight current word: ON'
|
||
return 1
|
||
endif
|
||
endfunction
|
||
|
||
" Removes trailing spaces
|
||
function AutoTrimWhitespace()
|
||
if exists("b:auto_trim_whitespace")
|
||
if b:auto_trim_whitespace == 1
|
||
let l:winview = winsaveview()
|
||
silent! %s/\s\+$//
|
||
call winrestview(l:winview)
|
||
endif
|
||
endif
|
||
endfunction
|
||
|
||
autocmd BufWritePre * :call AutoTrimWhitespace()
|
||
|
||
|
||
" Test fold mappings
|
||
nnoremap <silent> <Space> @=(foldlevel('.')?'za':'l')<CR>
|
||
vnoremap <Space> zf
|
||
inoremap jj <Esc>
|
||
|
||
" 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)}'
|
||
|