.vimrc
This commit is contained in:
parent
7cd46f4241
commit
a50d01abd6
1 changed files with 118 additions and 114 deletions
232
.vimrc
232
.vimrc
|
|
@ -1,55 +1,86 @@
|
|||
" ___ _ _ _
|
||||
" | _ ) __ _ _ _ __ _| |_( )___ __ _(_)_ __ _ _ __
|
||||
" | _ \/ _` | '_/ _` | / //(_-< \ V / | ' \| '_/ _|
|
||||
" |___/\__,_|_| \__,_|_\_\ /__/ (_)_/|_|_|_|_|_| \__|
|
||||
"
|
||||
" Let's have a look.
|
||||
" First, we are vim, not vi, so start as many others do with
|
||||
"
|
||||
" ** BASIC EDITOR SETTINGS **
|
||||
set nocompatible
|
||||
|
||||
" Set syntax and highlighting
|
||||
syntax on
|
||||
" baraknew is my own colorscheme. I used to use slate or dante.
|
||||
colorscheme baraknew
|
||||
"colorscheme slate
|
||||
"colorscheme dante
|
||||
colorscheme baraknew
|
||||
|
||||
" Set default spacing
|
||||
"set gfn=Monaco:h12:a
|
||||
" Allow background buffers. Super important for various tab modes.
|
||||
set hidden
|
||||
|
||||
" Set default spacing.
|
||||
" Hard tabs should show as 8.
|
||||
set ts=8
|
||||
" Soft tabs should be 2 wide, and we should use spaces.
|
||||
" (This is the Googler in me. I've converted to spaces over
|
||||
" the years because it really is more consistent.)
|
||||
set softtabstop=2
|
||||
set shiftwidth=2
|
||||
set expandtab
|
||||
" I like comma instead of slash, but that probably comes from playing
|
||||
" Nethack and Angband
|
||||
let mapleader = ","
|
||||
|
||||
" Set 'smart' things in Vim
|
||||
set smartcase
|
||||
" Use all the indent features
|
||||
set autoindent
|
||||
set smartindent
|
||||
set cindent
|
||||
" Make backspace remove indents and line breaks, like a normal editor
|
||||
set backspace=indent,eol,start
|
||||
|
||||
" Keep a bigger history
|
||||
set history=1000
|
||||
" Allow tab completion for files in command mode.
|
||||
set wildmenu
|
||||
set wildmode=list:longest
|
||||
" Show where you are in the file in the statusbar.
|
||||
set ruler
|
||||
|
||||
" I hate split above, so make it split below. Likewise, to the right.
|
||||
set splitbelow
|
||||
" For autocomplete, show a menu, show it when there's only one option,
|
||||
" and only complete the longest common bit instead of the whole thing (like
|
||||
" bash).
|
||||
set completeopt=menu,menuone,longest
|
||||
|
||||
" Some stuff for 256-Color consoles that I've forgotten.
|
||||
set t_Co=256
|
||||
set t_Sf=ESC[3%dm
|
||||
set t_Sb=ESC[4%dm
|
||||
"set t_kb=
|
||||
|
||||
" This is like HiglightTooLongLines below, but for modern vim. The problem is
|
||||
" that it highlights the column, even if your short. Good for measuring, bad for
|
||||
" my eyes.
|
||||
"if v:version >= 703
|
||||
"set relativenumber
|
||||
"set colorcolumn=81
|
||||
"endif
|
||||
|
||||
" ** FILETYPE SETTINGS **
|
||||
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
|
||||
|
|
@ -62,14 +93,35 @@ 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>")
|
||||
"
|
||||
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
|
||||
au BufEnter *.org call org#SetOrgFileType()
|
||||
|
||||
" 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.
|
||||
autocmd BufEnter * setlocal cursorline
|
||||
autocmd WinEnter * setlocal cursorline
|
||||
autocmd WinLeave * setlocal nocursorline
|
||||
setlocal cursorline
|
||||
|
||||
|
||||
" ** PLUGIN CONFIGURATION **
|
||||
" Vim/Unknown
|
||||
let python_highlight_all = 1
|
||||
let g:Tb_MaxSize=0
|
||||
let g:Tb_MapCTabSwitchBufs = 1
|
||||
|
||||
" Lusty plugins
|
||||
let g:LustyExplorerSuppressRubyWarning = 1
|
||||
let g:LustyJugglerSuppressRubyWarning = 1
|
||||
let g:LustyJugglerShowKeys = 'a'
|
||||
|
||||
" Buftabs
|
||||
let g:buftabs_only_basename = 1
|
||||
"let g:buftabs_in_statusline=1
|
||||
"
|
||||
" NERDTree
|
||||
let g:NERDChristmasTree = 1
|
||||
let g:NERDChristmasTree = 1
|
||||
let g:NERDTreeQuitOnOpen = 1
|
||||
|
|
@ -77,7 +129,6 @@ let g:NERDTreeWinPos = "right"
|
|||
let g:NERDTreeWinSize = 40
|
||||
let g:NERDTreeDirArrows=0
|
||||
|
||||
|
||||
" Tagbar plugin settings
|
||||
let g:tagbar_width = 40
|
||||
let g:tagbar_autofocus = 1
|
||||
|
|
@ -90,12 +141,11 @@ let Tlist_File_Fold_Auto_Close = 1
|
|||
let Tlist_WinWidth = 40
|
||||
let Tlist_Show_One_File = 0
|
||||
|
||||
" ConqueTerm
|
||||
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
|
||||
|
|
@ -103,24 +153,41 @@ au BufEnter *.org call org#SetOrgFileType()
|
|||
"let g:miniBufExplModSelTarget = 1
|
||||
"let g:miniBufExplForceSyntaxEnable = 1
|
||||
|
||||
" CommandT
|
||||
let g:CommandTMaxFiles = 1000
|
||||
let g:CommandTMaxDepth = 7
|
||||
|
||||
"Remappings
|
||||
"Open in tabs...
|
||||
|
||||
" ** 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<CR>
|
||||
"nnoremap gK :tabclose<CR>
|
||||
"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<CR>
|
||||
nmap gb :TlistToggle<CR>
|
||||
"nnoremap gx :Kwbd<CR>
|
||||
" :Kwbd (defined below) really kills a buffer dead, and closes the window.
|
||||
" gK is similar.
|
||||
nnoremap gc :Kwbd<CR>
|
||||
"nnoremap gc :bdelete<CR>
|
||||
nnoremap gK :bdelete!<CR>
|
||||
" I use gn/gp to cycle through open tabs
|
||||
nnoremap gn :bn<CR>
|
||||
nnoremap gp :bp<CR>
|
||||
nnoremap gz :pclose<CR>
|
||||
" 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 o<Esc>p
|
||||
" 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
|
||||
|
|
@ -132,22 +199,27 @@ xnoremap <Up> gk
|
|||
inoremap <Down> <C-o>gj
|
||||
inoremap <Up> <C-o>gk
|
||||
"nnoremap <C-i> <C-a>
|
||||
" 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 <C-a> ^
|
||||
nnoremap <C-e> $
|
||||
xnoremap <C-a> ^
|
||||
xnoremap <C-e> $
|
||||
inoremap <C-a> <C-O>^
|
||||
inoremap <C-e> <C-O>$
|
||||
|
||||
" Better fold mappings
|
||||
nnoremap <silent> <Space> @=(foldlevel('.')?'za':'l')<CR>
|
||||
vnoremap <Space> 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 <C-c> <Esc>
|
||||
inoremap jj <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>
|
||||
|
||||
" ** STATUSLINE **
|
||||
"
|
||||
set laststatus=2
|
||||
set statusline=%t "tail of the filename
|
||||
"set statusline+=[%{&ff}] "file format
|
||||
|
|
@ -162,28 +234,20 @@ set statusline+=%c, "cursor column
|
|||
set statusline+=%l/%L "cursor line/total lines
|
||||
set statusline+=\ %P "percent through file
|
||||
|
||||
|
||||
autocmd BufEnter * setlocal cursorline
|
||||
autocmd WinEnter * setlocal cursorline
|
||||
autocmd WinLeave * setlocal nocursorline
|
||||
setlocal cursorline
|
||||
|
||||
" Useful functions
|
||||
" ** SMALL FUNCTIONS THAT DON'T FIT AS PLUGINS ***
|
||||
|
||||
" Add capital W so I can be lazy about my shift jey
|
||||
if !exists(":W")
|
||||
command W :w
|
||||
endif
|
||||
|
||||
" CD to the path of the file I'm editing.
|
||||
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
|
||||
|
|
@ -199,39 +263,6 @@ function! s:DiffWithSaved()
|
|||
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)
|
||||
|
|
@ -260,8 +291,6 @@ 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
|
||||
|
|
@ -269,28 +298,9 @@ function! HighlightTooLongLines()
|
|||
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>
|
||||
let s:extrarc = expand($HOME . '/.vimrc_google')
|
||||
if filereadable(s:extrarc)
|
||||
exec ':so ' . s:extrarc
|
||||
endif
|
||||
|
||||
" Configure browser for haskell_doc.vim
|
||||
|
|
@ -322,7 +332,6 @@ 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.
|
||||
|
|
@ -362,11 +371,6 @@ 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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue