Advertisement
Guest User

Untitled

a guest
Feb 7th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 10.59 KB | None | 0 0
  1. " https://github.com/sontek/dotfiles/
  2. " ==========================================================
  3. " Dependencies - Libraries/Applications outside of vim
  4. " ==========================================================
  5. " Pep8 - http://pypi.python.org/pypi/pep8
  6. " Pyflakes
  7. " Ack
  8. " Rake & Ruby for command-t
  9. " nose, django-nose
  10.  
  11. " ==========================================================
  12. " Plugins included
  13. " ==========================================================
  14. " Pathogen
  15. "     Better Management of VIM plugins
  16. "
  17. " GunDo
  18. "     Visual Undo in vim with diff's to check the differences
  19. "
  20. " Pytest
  21. "     Runs your Python tests in Vim.
  22. "
  23. " Commant-T
  24. "     Allows easy search and opening of files within a given path
  25. "
  26. " Snipmate
  27. "     Configurable snippets to avoid re-typing common comands
  28. "
  29. " PyFlakes
  30. "     Underlines and displays errors with Python on-the-fly
  31. "
  32. " Fugitive
  33. "    Interface with git from vim
  34. "
  35. " Git
  36. "    Syntax highlighting for git config files
  37. "
  38. " Pydoc
  39. "    Opens up pydoc within vim
  40. "
  41. " Surround
  42. "    Allows you to surround text with open/close tags
  43. "
  44. " Py.test
  45. "    Run py.test test's from within vim
  46. "
  47. " MakeGreen
  48. "    Generic test runner that works with nose
  49. "
  50. " ==========================================================
  51. " Shortcuts
  52. " ==========================================================
  53. set nocompatible              " Don't be compatible with vi
  54. let mapleader=","             " change the leader to be a comma vs slash
  55.  
  56. " Seriously, guys. It's not like :W is bound to anything anyway.
  57. command! W :w
  58.  
  59. " Make esc key eliminate search highlighing
  60. nnoremap <esc> :noh<return><esc>
  61.  
  62. fu! SplitScroll()
  63.     :wincmd v
  64.     :wincmd w
  65.     execute "normal! \<C-d>"
  66.     :set scrollbind
  67.     :wincmd w
  68.     :set scrollbind
  69. endfu
  70.  
  71. nmap <leader>sb :call SplitScroll()<CR>
  72.  
  73.  
  74. "<CR><C-w>l<C-f>:set scrollbind<CR>
  75.  
  76. " sudo write this
  77. cmap W! w !sudo tee % >/dev/null
  78.  
  79. " Toggle the tasklist
  80. map <leader>td <Plug>TaskList
  81.  
  82. " Run pep8
  83. let g:pep8_map='<leader>8'
  84.  
  85. " run py.test's
  86. nmap <silent><Leader>tf <Esc>:Pytest file<CR>
  87. nmap <silent><Leader>tc <Esc>:Pytest class<CR>
  88. nmap <silent><Leader>tm <Esc>:Pytest method<CR>
  89. nmap <silent><Leader>tn <Esc>:Pytest next<CR>
  90. nmap <silent><Leader>tp <Esc>:Pytest previous<CR>
  91. nmap <silent><Leader>te <Esc>:Pytest error<CR>
  92.  
  93. " Run django tests
  94. map <leader>dt :set makeprg=python\ manage.py\ test\|:call MakeGreen()<CR>
  95.  
  96. " Reload Vimrc
  97. map <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
  98.  
  99. " open/close the quickfix window
  100. nmap <leader>c :copen<CR>
  101. nmap <leader>cc :cclose<CR>
  102.  
  103. " for when we forget to use sudo to open/edit a file
  104. cmap w!! w !sudo tee % >/dev/null
  105.  
  106. " ctrl-jklm  changes to that split
  107. map <c-j> <c-w>j
  108. map <c-k> <c-w>k
  109. map <c-l> <c-w>l
  110. map <c-h> <c-w>h
  111.  
  112. " and lets make these all work in insert mode too ( <C-O> makes next cmd
  113. "  happen as if in command mode )
  114. imap <C-W> <C-O><C-W>
  115.  
  116. " Open NerdTree
  117. map <leader>n :NERDTreeToggle<CR>
  118.  
  119. " Run command-t file search
  120. map <leader>f :CommandT<CR>
  121. " Ack searching
  122. nmap <leader>a <Esc>:Ack!
  123.  
  124. " Load the Gundo window
  125. map <leader>g :GundoToggle<CR>
  126.  
  127. " Jump to the definition of whatever the cursor is on
  128. map <leader>j :RopeGotoDefinition<CR>
  129.  
  130. " Rename whatever the cursor is on (including references to it)
  131. map <leader>r :RopeRename<CR>
  132. " ==========================================================
  133. " Pathogen - Allows us to organize our vim plugins
  134. " ==========================================================
  135. " Load pathogen with docs for all plugins
  136. filetype off
  137. call pathogen#runtime_append_all_bundles()
  138. call pathogen#helptags()
  139.  
  140. " ==========================================================
  141. " Basic Settings
  142. " ==========================================================
  143. syntax on                     " syntax highlighing
  144. filetype on                   " try to detect filetypes
  145. filetype plugin indent on     " enable loading indent file for filetype
  146. set number                    " Display line numbers
  147. set numberwidth=1             " using only 1 column (and 1 space) while possible
  148. set background=dark           " We are using dark background in vim
  149. set title                     " show title in console title bar
  150. set wildmenu                  " Menu completion in command mode on <Tab>
  151. set wildmode=full             " <Tab> cycles between all matching choices.
  152.  
  153. " don't bell or blink
  154. set noerrorbells
  155. set vb t_vb=
  156.  
  157. " Ignore these files when completing
  158. set wildignore+=*.o,*.obj,.git,*.pyc
  159. set wildignore+=eggs/**
  160. set wildignore+=*.egg-info/**
  161.  
  162. set grepprg=ack         " replace the default grep program with ack
  163.  
  164.  
  165. " Set working directory
  166. nnoremap <leader>. :lcd %:p:h<CR>
  167.  
  168. " Disable the colorcolumn when switching modes.  Make sure this is the
  169. " first autocmd for the filetype here
  170. "autocmd FileType * setlocal colorcolumn=0
  171.  
  172. """ Insert completion
  173. " don't select first item, follow typing in autocomplete
  174. set completeopt=menuone,longest,preview
  175. set pumheight=6             " Keep a small completion window
  176.  
  177.  
  178. """ Moving Around/Editing
  179. set cursorline              " have a line indicate the cursor location
  180. set ruler                   " show the cursor position all the time
  181. set nostartofline           " Avoid moving cursor to BOL when jumping around
  182. set virtualedit=block       " Let cursor move past the last char in <C-v> mode
  183. set scrolloff=10            " Keep 10 context lines above and below the cursor
  184. set backspace=2             " Allow backspacing over autoindent, EOL, and BOL
  185. set showmatch               " Briefly jump to a paren once it's balanced
  186. set nowrap                  " don't wrap text
  187. set linebreak               " don't wrap textin the middle of a word
  188. set autoindent              " always set autoindenting on
  189. set smartindent             " use smart indent if there is no indent file
  190. set tabstop=4               " <tab> inserts 4 spaces
  191. set shiftwidth=4            " but an indent level is 2 spaces wide.
  192. set softtabstop=4           " <BS> over an autoindent deletes both spaces.
  193. set expandtab               " Use spaces, not tabs, for autoindent/tab key.
  194. set shiftround              " rounds indent to a multiple of shiftwidth
  195. set matchpairs+=<:>         " show matching <> (html mainly) as well
  196. set foldmethod=indent       " allow us to fold on indents
  197. set foldlevel=99            " don't fold by default
  198.  
  199. " don't outdent hashes
  200. "inoremap # #
  201.  
  202. " close preview window automatically when we move around
  203. autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
  204. autocmd InsertLeave * if pumvisible() == 0|pclose|endif
  205.  
  206. """" Reading/Writing
  207. set noautowrite             " Never write a file unless I request it.
  208. set noautowriteall          " NEVER.
  209. set noautoread              " Don't automatically re-read changed files.
  210. set modeline                " Allow vim options to be embedded in files;
  211. set modelines=5             " they must be within the first or last 5 lines.
  212. set ffs=unix,dos,mac        " Try recognizing dos, unix, and mac line endings.
  213.  
  214. """" Messages, Info, Status
  215. set ls=2                    " allways show status line
  216. set vb t_vb=                " Disable all bells.  I hate ringing/flashing.
  217. set confirm                 " Y-N-C prompt if closing with unsaved changes.
  218. set showcmd                 " Show incomplete normal mode commands as I type.
  219. set report=0                " : commands always print changed line count.
  220. set shortmess+=a            " Use [+]/[RO]/[w] for modified/readonly/written.
  221. set ruler                   " Show some info, even without statuslines.
  222. set laststatus=2            " Always show statusline, even if only 1 window.
  223. set statusline=[%l,%v\ %P%M]\ %f\ %r%h%w\ (%{&ff})\ %{fugitive#statusline()}
  224.  
  225. " displays tabs with :set list & displays when a line runs off-screen
  226. " set listchars=tab:>-,eol:$,trail:-,precedes:<,extends:>
  227. " set list
  228.  
  229. """ Searching and Patterns
  230. set ignorecase              " Default to using case insensitive searches,
  231. set smartcase               " unless uppercase letters are used in the regex.
  232. set smarttab                " Handle tabs more intelligently
  233. set hlsearch                " Highlight searches by default.
  234. set incsearch               " Incrementally search while typing a /regex
  235.  
  236. """" Display
  237. if has("gui_running")
  238.     colorscheme blackboard
  239.     " Remove menu bar
  240.     set guioptions-=m
  241.     " Set font
  242.     set guifont=Monaco:h12
  243.  
  244.     " Remove toolbar
  245.     set guioptions-=T
  246. else
  247.     colorscheme molokai
  248. endif
  249.  
  250. " Paste from clipboard
  251. map <leader>p "+p
  252.  
  253. " Quit window on <leader>q
  254. nnoremap <leader>q :q<CR>
  255.  
  256. " hide matches on <leader>space
  257. nnoremap <leader><space> :nohlsearch<cr>
  258.  
  259. " Remove trailing whitespace on <leader>S
  260. nnoremap <leader>S :%s/\s\+$//<cr>:let @/=''<CR>
  261.  
  262. " Select the item in the list with enter
  263. inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  264.  
  265. " ==========================================================
  266. " Javascript
  267. " ==========================================================
  268. au BufRead *.js set makeprg=jslint\ %
  269.  
  270. " Use tab to scroll through autocomplete menus
  271. "autocmd VimEnter * imap <expr> <Tab> pumvisible() ? "<C-N>" : "<Tab>"
  272. "autocmd VimEnter * imap <expr> <S-Tab> pumvisible() ? "<C-P>" : "<S-Tab>"
  273.  
  274. let g:acp_completeoptPreview=1
  275.  
  276. " ===========================================================
  277. " FileType specific changes
  278. " ============================================================
  279. " Mako/HTML
  280. autocmd BufNewFile,BufRead *.mako,*.mak,*.jinja2 setlocal ft=html
  281. autocmd FileType html,xhtml,xml,css setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
  282.  
  283. " Python
  284. "au BufRead *.py compiler nose
  285. au FileType python set omnifunc=pythoncomplete#Complete
  286. au FileType python setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4 smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
  287. au FileType coffee setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4 smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
  288. au BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
  289. " Don't let pyflakes use the quickfix window
  290. let g:pyflakes_use_quickfix = 0
  291.  
  292.  
  293.  
  294. " Add the virtualenv's site-packages to vim path
  295. if has('python')
  296. py << EOF
  297. import os.path
  298. import sys
  299. import vim
  300. if 'VIRTUAL_ENV' in os.environ:
  301.     project_base_dir = os.environ['VIRTUAL_ENV']
  302.     sys.path.insert(0, project_base_dir)
  303.     activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
  304.     execfile(activate_this, dict(__file__=activate_this))
  305. EOF
  306. endif
  307.  
  308. " Load up virtualenv's vimrc if it exists
  309. if filereadable($VIRTUAL_ENV . '/.vimrc')
  310.     source $VIRTUAL_ENV/.vimrc
  311. endif
  312.  
  313. set colorcolumn=79
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement