Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c6fbcd22dc
Fetching contributors…

Cannot retrieve contributors at this time

497 lines (397 sloc) 13.868 kb
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Dotfile, Runpath, Pathogen setup
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set runtimepath=~/dotfiles/vim,$VIMRUNTIME
" Pathogen init
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
" Source the dotfiles vimrc
" source ~/dotfiles/vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if &compatible
set nocompatible " Don't care about VI-compatibility
endif
" How much history to keep around
set history=800
" With a map leader it's possible to do extra key combinations like <leader>w
" saves the current file
let mapleader = '\'
let g:mapleader = '\'
set timeout timeoutlen=10000 ttimeoutlen=250
" Fast editing of the vimrc
map <leader>e :e! $MYVIMRC<CR>
" Enable filetype plugin
filetype on
filetype plugin on
filetype indent on
" No BOM in utf8 files please
set nobomb
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => UI
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Scroll offset - space below & above cursor while scrolling
set scrolloff=3
" Get a cool menu for tab completing file names
set wildmenu
" Show the column number in the status bar
set ruler
" 30 char wide ruler, separation point, ':', 'b', buffer number, file type,
" modified flag, readonly flag, preview window flag, ' ', line number, ',',
" column number, virtual column number, ' ', percentage through file
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
" Command bar height
set cmdheight=1
" One of the most important options to activate. Allows you to switch from an
" unsaved buffer without saving it first. Also allows you to keep an undo
" history for multiple files. Vim will complain if you try to quit without
" saving, and swap files will keep you safe if your computer crashes.
set hidden
" allow backspacing over everything in insert mode - autoindent, end of line
" (join lines), past the start of an insert
set backspace=indent,eol,start
set whichwrap+=<,>,h,l
" Don't redraw while executing macros
set nolazyredraw
" Don't redraw the screen in the middle of executing macros
"set lazyredraw
" Set magic on for regular expression
set magic
" Show matching bracets when text indicator is over them
set showmatch
" How many tenth of a second to blink
set matchtime=2
" No sound on errors
set noerrorbells
set novisualbell
"set visualbell t_vb=
set t_vb=
set timeoutlen=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Search
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hlsearch
" Find as you type - Will go back to where the cursor was if you press <esc>
set incsearch
" Match - as part of whole word seach using * and # Use case insensitive
set iskeyword+=-
" search, except when using capital letters
set ignorecase
set smartcase
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts, Gvim Specific
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax highlighting
syntax enable
if has("gui_running")
" 90 column wide gvim
set columns=90
" 50 lines tall gvim
set lines=50
"Toggle Menu and Toolbar
set guioptions-=T
set guioptions-=m
map <silent> <F7> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>
\endif<CR>
" Instruct VIM that the term has 256 colors
set t_Co=256
" Scheme settings
set background=dark
colorscheme murphy
" No numbers in left column
set nonumber
else
" Scheme settings
set background=dark
"colorscheme murphy
" No numbers in left column
set nonumber
endif
" Encoding mangling
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8 bomb
set fileencodings=ucs-bom,utf-8,latin1
endif
" Set language to the usa
try
lang en_US
catch
endtry
" Default file types
set fileformats=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("persistent_undo")
" Persistent undo directory for storing undos
set undodir=~/dotfiles/vim/undo/
set undofile
endif
" Backup directories
set backupdir=~/dotfiles/vim/backup/
set directory=~/dotfiles/vim/swap/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use hard tabs please! Watch out for files with soft tabs that don't have a
" modeline present, especially Python files.
set noexpandtab
set shiftwidth=4
" Make tabs appear four spaces wide (default is 8 spaces)
set tabstop=4
" Useful for backspacing, it will delete shiftworth of space at a time
set smarttab
" Wrap only at word boundaries (default is at any character)
set linebreak
" Width of the text being inserted
set textwidth=0
" Wrap lines
"set wrap
" Keep the indent level when hitting Return
set autoindent
" Use smart indenting (mostly useful for C/C++ files)
set smartindent
" Don't indent Python really poorly
set cindent
" Highlight trailing whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Visual mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
" which is the default
map Y y$
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"nop
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Insert mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"EXPERIMENTAL Remap omni-completion to CTRL+SPACE
inoremap <C-space> <C-x><C-o>
let g:py_select_leading_comments = 0
" END EXPER
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart way to move btw. windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,300 bd!<cr>
" Buffer stuff
map <leader>bp :bp<CR>
map <leader>bn :bn<CR>
map <leader>ls :ls<CR>
" Tab configuration
map <leader>tn :tabnew %<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <C-I> :tabprevious<cr>
map <C-O> :tabnext<cr>
" When pressing <leader>cd switch to the directory of the open buffer map
" <leader>cd :cd %:p:h<cr>
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set showtabline=1
catch
endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Statusline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ask to save files
set confirm
" show partial commands in status line and selected characters/lines in visual mode
set showcmd
"Always have a status line
set laststatus=2
" 2 width - buffer number, ':', '*', path to file in the buffer, '*', ' ', '
" ', highlight group, readonly flag, modified flag, highlight group, ' ',
" separation point, file type, 15 char wide 'ruler', line number, '/', Number
" of lines, ':', column number, ' ', '(', percentage through file, '%', ')'
set statusline=%2n:*%-32.32f%*\ \ %2*%r%m%*\ %=%y\%15(%l/%L:%c\ (%2p%%)%)
" show mode in status bar (insert/replace/...)
set showmode
" show typed command in status bar
set showcmd
" show file in titlebar
set title
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Timestamp
iab xdate <C-R>=strftime("%m/%d/%Y")<CR>
iab xtime <C-R>=strftime("%H:%M:%S")<CR>
" Python
iab ipdb <C-R>iimport ipdb; ipdb.set_trace()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"nop
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command-T configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:CommandTMaxHeight = 15
let g:CommandTMaxFiles = 100000
"let g:CommandTMatchWindowReverse = 1
"set wildignore+=*.o,*.obj,.git,*.pyc,*.so
noremap <leader>t :CommandT<cr>
noremap <leader>tf :CommandTFlush<cr>
" Fix commandT with tmux
map <Esc>[A <Up>
map <Esc>[B <Down>
map <Esc>[C <Right>
map <Esc>[D <Left>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spellchecking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("spell")
" toggle spelling with ss
map <leader>ss :set spell!<CR><Bar>:echo "Spell Check: " .strpart("OffOn", 3 * &spell, 3)<CR>
" they were using white on white
highlight PmenuSel ctermfg=black ctermbg=lightgray
" limit it to just the top 10 items
set sps=best,10
"Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>sg z=
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Python
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let python_highlight_all = 1
let python_highlight_indent_errors = 0
let python_highlight_space_errors = 0
" Python comment/uncomment
map <leader>c :s/^/#/<CR>:/asdfnvaewontgaoghnsdfafd<CR>
map <leader>x :s/^#//<CR>:/asdfnvaewontgaoghnsdfafd<CR>
"" this makes python auto indent less retarded
let g:pyindent_open_paren = '&sw * 1'
let g:pyindent_nested_paren = '&sw'
let g:pyindent_continue = '&sw * 1'
" Tweaking the complete stuff to stop reading from the massive directory tree of files
set complete=.,w,b,u,t
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => File type specific settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! YelpSettings()
set noexpandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
endfunction
function! HaskellSettings()
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
endfunction
if has("autocmd")
" When vimrc is edited, reload it
autocmd! bufwritepost .vimrc source $MYVIMRC
" conkyrc
autocmd BufRead,BufNewFile ~/.conky/* set filetype=conkyrc
" autocmd FileType python source ~/.vim/python_fold.vim
autocmd FileType python set omnifunc=pythoncomplete#Complete
" Remove cindent, smartindent
autocmd FileType python set nocindent nosmartindent
autocmd FileType python syn keyword pythonDecorator True None False self
" Set the proper filetype for these cheetah templates
autocmd BufRead,BufNewFile *.js.tmpl set filetype=javascript
autocmd BufRead,BufNewFile *.css.tmpl set filetype=css
" Yelp's python settings
autocmd BufNewFile,BufRead ~/pg/* call YelpSettings()
" Haskell settings
autocmd FileType haskell call HaskellSettings()
" Highlight trailing whitespace
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => MISC
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Select longest common text of all matches, and menu will come up even with one match
set completeopt=longest,menuone
" Options for formatting text (i.e. for use with gq) - If any formatting is fishy check this
set formatoptions=roq
" toggle indent on/off
map <leader>ii :set cin!<CR>:set ai!<CR>:set si!<CR><Bar>:echo "Indenting: " .strpart("OffOn", 3 * &cin, 3)<CR>
inoremap <leader>ii <Esc>:set cin!<CR>:set ai!<CR>:set si!<CR><Bar>:echo "Indenting: " .strpart("OffOn", 3 * &cin, 3)<CR>i
" toggle paste on/off
map <leader>pp :set paste!<Bar>set paste?<CR>
inoremap <leader>pp <Esc>:set paste!<Bar>set paste?<CR>i
" Stupid WQ/wq stuff
command! WQ wq
command! Wq wq
command! W w
command! Q q
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => CTags
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tags=tags;$HOME
" ctags love
" Open the definition in a new tab
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
" Open the tab in a vsplit
map <leader>] :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <silent> <leader>f :TlistToggle<CR>
let Tlist_GainFocus_On_ToggleOpen=1
let Tlist_Process_File_Always=1
let Tlist_Show_Menu=1
let Tlist_Enable_Fold_Column=0
let g:gist_detect_filetype = 1
" Rebuild the ctag database
command! RefreshCtag !/usr/bin/ctags --totals=yes --languages=python --fields=+iaS --python-kinds=-i --sort=yes --extra=+q -f ~/tags --exclude=@/nail/home/pberens/vim_ignorelist -R
"-L <(find ~/pg/yelp-main/ -name '*.py')
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Home Grown functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ImportList(name)
let filename=expand("%")
" Build the command to execute
let cmd="pyflakes "
let cmd.=filename
let cmd.=" | sed -n \"/undefined name/s/.*: undefined name '\\(.*\\)'/from "
let cmd.=a:name
let cmd.=" import \\1/p\" | sort | uniq"
put=system(cmd)
endfunction
command! -nargs=1 ImportList :call ImportList("<args>")
Jump to Line
Something went wrong with that request. Please try again.