public
Description: My personal VIM configurations
Homepage:
Clone URL: git://github.com/technicalpickles/pickled-vim.git
pickled-vim / vimrc
100644 252 lines (193 sloc) 7.779 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
" Section: configuration
"
  scriptencoding utf-8
 
  " I like pretty colors
  colorscheme ir_black
 
  " These two enable syntax highlighting
  set nocompatible " We're running Vim, not Vi!
  syntax on " Enable syntax highlighting
 
  " Enable filetype-specific indenting and plugins
  filetype plugin indent on
 
  " show the `best match so far' as search strings are typed
  set incsearch
 
  " Highlight search results once found:
  set hlsearch
 
  " highlight the current line the cursor is on
  set cursorline
  "sm: flashes matching brackets or parentheses
  set showmatch
 
  "sta: helps with backspacing because of expandtab
  set smarttab
 
  " Change <Leader>
  let mapleader = ","
 
  " Set temporary directory (don't litter local dir with swp/tmp files)
  set directory=/tmp/
 
  " When scrolling off-screen do so 3 lines at a time, not 1
  set scrolloff=3
 
  " enable line numbers
  set number
  setlocal numberwidth=5
 
  " Enable tab complete for commands.
  " first tab shows all matches. next tab starts cycling through the matches
  set wildmenu
  set wildmode=list:longest,full
 
  " Display extra whitespace
  "set list listchars=tab:»·,trail:·
 
  " don't make it look like there are line breaks where there aren't:
  "set nowrap
 
  " assume the /g flag on :s substitutions to replace all matches in a line:
  set gdefault
 
  " Load matchit (% to bounce from do to end, etc.)
  runtime! macros/matchit.vim
 
  " Nice statusbar
  set laststatus=2
  set statusline=\ "
  set statusline+=%f\ " file name
  set statusline+=[
  set statusline+=%{strlen(&ft)?&ft:'none'}, " filetype
  set statusline+=%{&fileformat}] " file format
  set statusline+=%h%1*%m%r%w%0* " flag
  set statusline+=%= " right align
  set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
 
  " enable setting title
  set title
  " configure title to look like: Vim /path/to/file
  set titlestring=VIM:\ %-25.55F\ %a%r%m titlelen=70
 
  " Make backspace work in insert mode
  set backspace=indent,eol,start
 
  " can has foldin plz?
  set foldenable
  set foldmethod=syntax
  set foldlevel=999 " make it really high, so they're not displayed by default
  
 
  " Turn off rails bits of statusbar
  let g:rails_statusline=0
 
  " quit NERDTree after openning a file
  let NERDTreeQuitOnOpen=1
  " colored NERD Tree
  let NERDChristmasTree = 1
  let NERDTreeHighlightCursorline = 1
  let NERDTreeShowHidden = 1
  " map enter to activating a node
  let NERDTreeMapActivateNode='<CR>'
  let NERDTreeIgnore=['\.git','\.DS_Store']
 
  " limit number of results shown for performance
  let g:fuzzy_matching_limit=60
  " ignore stuff that can't be openned, and generated files
  let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**"
  " increate the number of files scanned for very large projects
  let g:fuzzy_ceiling=20000
  " display relative path, instead of abbrevated path (lib/jeweler.rb vs
  " l/jeweler.rb)
  let g:fuzzy_path_display = 'relative_path'
 
  let g:browser = 'open '
 
  augroup myfiletypes
    " Clear old autocmds in group
    autocmd!
    " autoindent with two spaces, always expand tabs
    autocmd FileType ruby,eruby,yaml set autoindent shiftwidth=2 softtabstop=2 expandtab
    autocmd FileType vim set autoindent tabstop=2 shiftwidth=2 softtabstop=2 expandtab
    autocmd FileType cucumber set autoindent tabstop=2 shiftwidth=2 softtabstop=2 expandtab
    " markdown goodness
    autocmd BufRead *.mkd set autoindent formatoptions=tcroqn2 comments=n:>
    au BufRead,BufNewFile *etc/nginx/* set ft=nginx
    " treat rackup files like ruby
    au BufRead,BufNewFile *.ru set ft=ruby
  augroup END
 
 
  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
        \ if line("'\"") > 0 && line("'\"") <= line("$") |
        \ exe "normal g`\"" |
        \ endi
 
  " Turn on language specific omnifuncs
  autocmd FileType ruby set omnifunc=rubycomplete#Complete
  autocmd FileType python set omnifunc=pythoncomplete#Complete
  autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
  autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
  autocmd FileType css set omnifunc=csscomplete#CompleteCSS
  autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
  autocmd FileType php set omnifunc=phpcomplete#CompletePHP
  autocmd FileType c set omnifunc=ccomplete#Complete
 
 
  " have some fun with bufexplorer
  let g:bufExplorerDefaultHelp=0 " Do not show default help.
  let g:bufExplorerShowRelativePath=1 " Show relative paths.
 
" IRB {{{
  autocmd FileType irb inoremap <buffer> <silent> <CR> <Esc>:<C-u>ruby v=VIM::Buffer.current;v.append(v.line_number, eval(v[v.line_number]).inspect)<CR>
 
" Section: functions
 
  function! s:RunShellCommand(cmdline)
    botright new
 
    setlocal buftype=nofile
    setlocal bufhidden=delete
    setlocal nobuflisted
    setlocal noswapfile
    setlocal nowrap
    setlocal filetype=shell
    setlocal syntax=shell
 
    call setline(1,a:cmdline)
    call setline(2,substitute(a:cmdline,'.','=','g'))
    execute 'silent $read !'.escape(a:cmdline,'%#')
    setlocal nomodifiable
    1
  endfunction
 
  " Open the Rails ApiDock page for the word under cursor, using the 'open'
  " command
  function! OpenRailsDoc(keyword)
    let url = 'http://apidock.com/rails/'.a:keyword
    exec '!'.g:browser.' '.url
  endfunction
 
  " Open the Ruby ApiDock page for the word under cursor, using the 'open'
  " command
  function! OpenRubyDoc(keyword)
    let url = 'http://apidock.com/ruby/'.a:keyword
    exec '!'.g:browser.' '.url
  endfunction
 
" Section: commands
 
  " Shell
  command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
 
  " Ruby code metrics
  command! -complete=file -nargs=+ Reek :Shell reek <q-args>
  command! -complete=file -nargs=+ Roodi :Shell roodi <q-args>
  command! -complete=file -nargs=+ Flog :Shell flog -m -I lib <q-args> 2>/dev/null
 
" Section: mappings
 
  " Tab navigation
  nmap <leader>tn :tabnext<CR>
  nmap <leader>tp :tabprevious<CR>
  nmap <leader>te :tabedit
 
  " Remap F1 from Help to ESC. No more accidents.
  nmap <F1> <Esc>
  map! <F1> <Esc>
 
  nmap <leader>sh :Shell
 
  " Quick way to leave insert mode, without leaving homerow
  imap ii <Esc>
 
  " insert hashrocket, =>, with control-l
  imap <C-l> <Space>=><Space>
 
  " align hashrockets with <leader>t control-l
  vmap <leader>t<C-l> :Align =><CR>
 
  " Toggle NERDTree with <leader>d
  map <silent> <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
 
  " TextMate fuzzy finder with <leader>t
  map <silent> <leader>t :FuzzyFinderTextMate<CR>
  " TextMate fuzzy finder in a new horizontal split window
  map <silent> <leader>st <C-w><C-s>:FuzzyFinderTextMate<CR>
  " TextMate fuzzy finder in a new vertical split window
  map <silent> <leader>vt <C-w><C-v>:FuzzyFinderTextMate<CR>
 
  " FuzzyFinder tags with <leader>T
  nnoremap <silent> <leader>T :FuzzyFinderTag!<CR>
 
  " <leader>F to begin searching with ack
  map <leader>F :Ack<space>
 
  " search next/previous -- center in page
  nmap n nzz
  nmap N Nzz
  nmap * *Nzz
  nmap # #nzz
 
  " Yank from the cursor to the end of the line, to be consistent with C and D.
  nnoremap Y y$
 
  " Hide search highlighting
  map <silent> <leader>nh :nohls <CR>
 
  " toggle Quickfix window with <leader>q
  map <silent> <leader>q :QFix<CR>
 
  nnoremap <leader>irb :<C-u>below new<CR>:setfiletype irb<CR>:set syntax=ruby<CR>:set buftype=nofile<CR>:set bufhidden=delete<CR>i
 
  " Easily lookup documentation on apidock
  noremap <leader>rb :call OpenRubyDoc(expand('<cword>'))<CR>
  noremap <leader>rr :call OpenRailsDoc(expand('<cword>'))<CR>