Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

407 lines (333 sloc) 13.048 kb
" https://github.com/sontek/dotfiles/
" ==========================================================
" Dependencies - Libraries/Applications outside of vim
" ==========================================================
" Pep8 - http://pypi.python.org/pypi/pep8
" Pyflakes
" Ack
" Rake & Ruby for command-t
" nose, django-nose
" ==========================================================
" Plugins included
" ==========================================================
" Pathogen
" Better Management of VIM plugins
"
" GunDo
" Visual Undo in vim with diff's to check the differences
"
" Pytest
" Runs your Python tests in Vim.
"
" Commant-T
" Allows easy search and opening of files within a given path
"
" Snipmate
" Configurable snippets to avoid re-typing common comands
"
" PyFlakes
" Underlines and displays errors with Python on-the-fly
"
" Fugitive
" Interface with git from vim
"
" Git
" Syntax highlighting for git config files
"
" Pydoc
" Opens up pydoc within vim
"
" Surround
" Allows you to surround text with open/close tags
"
" Py.test
" Run py.test test's from within vim
"
" MakeGreen
" Generic test runner that works with nose
"
" ==========================================================
" Shortcuts
" ==========================================================
set nocompatible " Don't be compatible with vi
"let mapleader="," " change the leader to be a comma vs slash
" Seriously, guys. It's not like :W is bound to anything anyway.
try
command! W :w
catch
"in a very stripped down version (eg crontab VISUAL)
finish
endtry
fu! SplitScroll()
:wincmd v
:wincmd w
execute "normal! \<C-d>"
:set scrollbind
:wincmd w
:set scrollbind
endfu
nmap <leader>sb :call SplitScroll()<CR>
set t_Co=256
"<CR><C-w>l<C-f>:set scrollbind<CR>
" sudo write this
cmap W! w !sudo tee % >/dev/null
" Toggle the tasklist
map <leader>td <Plug>TaskList
"
let g:CSApprox_verbose_level =0
" Run pep8
let g:pep8_map='<leader>pep'
" run py.test's
nmap <silent><Leader>tf <Esc>:Pytest file<CR>
nmap <silent><Leader>tc <Esc>:Pytest class<CR>
nmap <silent><Leader>tm <Esc>:Pytest method<CR>
nmap <silent><Leader>tn <Esc>:Pytest next<CR>
nmap <silent><Leader>tp <Esc>:Pytest previous<CR>
nmap <silent><Leader>te <Esc>:Pytest error<CR>
" Run django tests
map <leader>dt :set makeprg=python\ manage.py\ test\|:call MakeGreen()<CR>
" Reload Vimrc
map <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
" open/close the quickfix window
nmap <leader>c :copen<CR>
nmap <leader>cc :cclose<CR>
" for when we forget to use sudo to open/edit a file
cmap w!! w !sudo tee % >/dev/null
" ctrl-<j,k> moves current line/block up/down
nnoremap <c-k> ddkP
nnoremap <c-j> ddp
vnoremap <c-j> dp'[V']
vnoremap <c-k> dkP'[V']
" and lets make these all work in insert mode too ( <C-O> makes next cmd
" happen as if in command mode )
imap <C-W> <C-O><C-W>
" Open NerdTree
map <leader>n :NERDTreeToggle<CR>
" Run command-t file search
map <leader>f :CommandT<CR>
" Ack searching
nmap <leader>a <Esc>:Ack!
" Load the Gundo window
map <leader>g :GundoToggle<CR>
" Jump to the definition of whatever the cursor is on
map <leader>j :RopeGotoDefinition<CR>
" Rename whatever the cursor is on (including references to it)
map <leader>r :RopeRename<CR>
"Auto imports For django
let g:ropevim_autoimport_modules = ["os", "datetime","django"]
" ==========================================================
" Pathogen - Allows us to organize our vim plugins
" ==========================================================
" Load pathogen with docs for all plugins
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" ==========================================================
" Basic Settings
" ==========================================================
syntax on " syntax highlighing
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
"set number " Display line numbers
set numberwidth=1 " using only 1 column (and 1 space) while possible
set background=dark " We are using dark background in vim
set title " show title in console title bar
set wildmenu " Menu completion in command mode on <Tab>
set wildmode=longest,list,full " <Tab> cycles between all matching choices.
" don't bell or blink
set noerrorbells
set vb t_vb=
" Ignore these files when completing
set wildignore+=*.o,*.obj,.git,*.pyc
set wildignore+=eggs/**
set wildignore+=*.egg-info/**
"local virtualenv env convention
set wildignore+=env/bin,env/bin,env/include,env/share
set wildignore+=env/local,env/lib
set grepprg=ack " replace the default grep program with ack
" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>
" Disable the colorcolumn when switching modes. Make sure this is the
" first autocmd for the filetype here
"autocmd FileType * setlocal colorcolumn=0
""" Insert completion
" don't select first item, follow typing in autocomplete
set completeopt=menuone,longest,preview
set pumheight=6 " Keep a small completion window
""" Moving Around/Editing
set cursorline " have a line indicate the cursor location
set ruler " show the cursor position all the time
set nostartofline " Avoid moving cursor to BOL when jumping around
set virtualedit=block " Let cursor move past the last char in <C-v> mode
set scrolloff=3 " Keep 3 context lines above and below the cursor
set backspace=2 " Allow backspacing over autoindent, EOL, and BOL
set showmatch " Briefly jump to a paren once it's balanced
set nowrap " don't wrap text
set linebreak " don't wrap textin the middle of a word
set autoindent " always set autoindenting on
set smartindent " use smart indent if there is no indent file
set tabstop=4 " <tab> inserts 4 spaces
set shiftwidth=4 " but an indent level is 2 spaces wide.
set softtabstop=4 " <BS> over an autoindent deletes both spaces.
set expandtab " Use spaces, not tabs, for autoindent/tab key.
set shiftround " rounds indent to a multiple of shiftwidth
set matchpairs+=<:> " show matching <> (html mainly) as well
set foldmethod=indent " allow us to fold on indents
set foldlevel=99 " don't fold by default
" don't outdent hashes
"inoremap # #
" close preview window automatically when we move around
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"""" Reading/Writing
set noautowrite " Never write a file unless I request it.
set noautowriteall " NEVER.
set noautoread " Don't automatically re-read changed files.
set modeline " Allow vim options to be embedded in files;
set modelines=5 " they must be within the first or last 5 lines.
set ffs=unix,dos,mac " Try recognizing dos, unix, and mac line endings.
"""" Messages, Info, Status
set ls=2 " allways show status line
set vb t_vb= " Disable all bells. I hate ringing/flashing.
"set confirm " Y-N-C prompt if closing with unsaved changes.
set hidden
set showcmd " Show incomplete normal mode commands as I type.
set report=0 " : commands always print changed line count.
set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written.
set ruler " Show some info, even without statuslines.
set laststatus=2 " Always show statusline, even if only 1 window.
if has('python')
set stl=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ %{fugitive#statusline()}\ \ [buf\ %n]
else
set stl=%-f%r\ %2*%m%*\ \ \ \ [%l:%c]\ %{fugitive#statusline()}\ \ [buf\ %n]
endif
" displays tabs with :set list & displays when a line runs off-screen
" set listchars=tab:>-,eol:$,trail:-,precedes:<,extends:>
set listchars=tab:>-,trail:-,nbsp:+
set list
""" Searching and Patterns
"set ignorecase " Default to using case insensitive searches,
set smartcase " unless uppercase letters are used in the regex.
set smarttab " Handle tabs more intelligently
set hlsearch " Highlight searches by default.
"set incsearch " Incrementally search while typing a /regex
"""" Display
if has("gui_running")
colorscheme desert
set guioptions+=aegimtTLlRrb
set guioptions-=aegimtTLlRrb
else
colorscheme desert
endif
" Paste from clipboard
map <leader>p "+p
" Quit window on <leader>q
"nnoremap <leader>q :q<CR>
"
" hide matches on <leader>space
nnoremap <leader><space> :nohlsearch<cr>
" Remove trailing whitespace on <leader>S
nnoremap <leader>S :%s/\s\+$//<cr>:let @/=''<CR>
" Select the item in the list with enter
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" ==========================================================
" Javascript
" ==========================================================
au BufRead *.js set makeprg=jslint\ %
" Use tab to scroll through autocomplete menus
"autocmd VimEnter * imap <expr> <Tab> pumvisible() ? "<C-N>" : "<Tab>"
"autocmd VimEnter * imap <expr> <S-Tab> pumvisible() ? "<C-P>" : "<S-Tab>"
let g:acp_completeoptPreview=1
" ===========================================================
" FileType specific changes
" ============================================================
" Mako/HTML
autocmd BufNewFile,BufRead *.mako,*.mak,*.jinja2 setlocal ft=html
autocmd FileType html,xhtml,xml,css setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" Python
"au BufRead *.py compiler nose
au FileType python set omnifunc=pythoncomplete#Complete
au FileType python setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4 smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
au FileType python set statusline=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ %{fugitive#statusline()}\ \ [buf\ %n]
au BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
" Don't let pyflakes use the quickfix window
let g:pyflakes_use_quickfix = 0
" Add the virtualenv's site-packages to vim path
if has("python")
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
#Old school project assumptions. Note This assumes pwd is project dir
if os.path.exists('settings.py'):
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
else:
#look for django 1.4 style settings eg /<project>/<project>/settings.py
#created by a django_admin.py startproject
cur_dir = os.path.join(os.getcwd().split('/').pop())
if os.path.exists(os.path.join(cur_dir,'settings.py')):
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % cur_dir
else:
#Your on your own. Set to fail loudly
os.environ['DJANGO_SETTINGS_MODULE'] = ''
#add the pwd to sys path as it is not appearing in
sys.path.insert(0,os.getcwd())
EOF
map <F11> :!ctags -R -f ./tags `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`<CR>
" Load up virtualenv's vimrc if it exists
if filereadable($VIRTUAL_ENV . '/.vimrc')
source $VIRTUAL_ENV/.vimrc
endif
endif
if version >= 703
set colorcolumn=79
endif
" Diff
"
function! s:diff_maps()
if &diff
nnoremap <buffer> hhh :diffget 2//<cr>
nnoremap <buffer> lll :diffget 3//<cr>
endif
endfunction
au BufEnter * call s:diff_maps()
"Esoteric maps
"kk - move to the end of the line (how often do you type trekking?)
"jj - move to the next line (indents)
inoremap jj <esc>o
inoremap kk <esc>a
inoremap KK <esc>A
inoremap JJ <esc> a
"django stuff
if filereadable('manage.py')
au FileType python set ft=python.django
au FileType html set ft=htmldjango
au FileType text set ft=htmldjango
au FileType htmldjango set omnifunc=htmldjangocomplete#CompleteDjango
"Get tag generation out of the way
if !filereadable('tags')
norm <f11>
endif
endif
"{% %} tweak for htmldjango
au FileType htmldjango inoremap {% {% %}<left><left><left>
au FileType htmldjango set omnifunc=htmldjangocomplete#CompleteDjango
au FileType python set textwidth=79
"Pep8 all the time
"au BufWritePost *.py norm \pep
au Filetype python nnoremap \ppp :%!autopep8 -i %<cr>
"trim whitespace
nnoremap <leader>w :%s/\s\+$//<cr>
"ol'school surround map
vmap s S
"Paste toggle
set pastetoggle=<f12>
"let g:acp_behaviorSnipmateLength=1
let g:DirDiffExcludes = "CVS,*.class,*.exe,.*.swp,.git,*.pyc"
set path+=**/templates/
set path+=**/static/
Jump to Line
Something went wrong with that request. Please try again.