-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
409 lines (371 loc) · 15.3 KB
/
vimrc
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
"some hints
"replace all tabs in file with spaces:
":retab
"should come first since it changes other options
set nocompatible "use vim defaults, not vi defaults, required for vundle but also is just plain good
filetype off "required for vundle
"set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-scripts/genutils'
Plugin 'vim-scripts/AutoComplPop'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'majutsushi/tagbar'
Plugin 'vim-scripts/taglist.vim'
Plugin 'MattesGroeger/vim-bookmarks'
Plugin 'thisivan/vim-bufexplorer'
Plugin 'tpope/vim-fugitive'
Plugin 'kchmck/vim-coffee-script'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'terryma/vim-expand-region'
Plugin 'fatih/vim-go'
Plugin 'digitaltoad/vim-jade'
Plugin 'tpope/vim-rails'
Plugin 'kana/vim-textobj-user'
call vundle#end()
filetype plugin indent on " required for vundle
"load juggler plugin
set rtp+=~/.vim/bundle/juggler
helptags ~/.vim/bundle/juggler/doc
"whitespace - has to come before other ColorScheme commands
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=darkred guibg=darkred "color of bad whitespace
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$\|\t/ "insert mode don't match trailing whitespace
autocmd InsertLeave * match ExtraWhitespace /\s\+$\|\t/ "non-insert mode match all whitespace
autocmd BufWinEnter * match ExtraWhitespace /\s\+$\|\t/ "opening a new buffer match all whitespace
"set list "tabs show as CTRL-I, end of line shows as $
"set listchars=tab:>.,trail:.,extends:#,nbsp:. "tab = >., trailing space = ., line extends past screen = #, non-breakable space = .
"misc
syntax enable "enable syntax highlighting
set t_Co=256 "force vim to assume our terminal can display 256 colors
set background=dark "use colors that look good on a dark background
"set mouse=a
"colorscheme mine256 "use mine256 colorscheme
colorscheme xoria256 "use xoria256 colorscheme
"colorscheme mustang "use mustang colorscheme
set modelines=2 "only look at the top 2 lines to check for modelines
set laststatus=2 "always show a status line
set backspace=indent,eol,start "make backspace work better
set cursorline "highlight line cursor is on
set cursorcolumn "highlight column cursor is on
set scrolloff=999 "keep current line centered vertically
set ai "autoindent - copy indent from current line when starting new line
set si "smartindent - add additional indent after {, if, def, etc.
set ts=2 sts=2 sw=2 et "tab/softtab = 2 spaces, shiftwidth (autoindent) = 2 spaces, insert spaces instead of tab. these may be overridden by filetype plugins
filetype on "turn on filetype detection
filetype plugin on "when a filetype is detected, load the plugin for that filetype
filetype indent on "when a filetype is detected, load the indent for that filetype
set textwidth=0 "don't try to start a new line if current line starts to get really long
set wrapmargin=0 "don't wrap when we reach the right margin
set incsearch "incremental search
"set completeopt=longest,menuone,preview "in insert mode when doing completions, only insert longest common text, use popup menu even if only one match, show extra info about selected
set completeopt=menuone
set nohlsearch "don't highlight additional matches
"set ignorecase "ignore case when using ctags
set hidden "hide buffers rather than closing them when switching away from them
set history=1000 "remember more commands and search history
set undolevels=1000 "use many muchos levels of undo
set wildignore=vendor/bundle/**,tmp/**,*.gif,*.png,*.jpg,*.swp,*.bak,*.pyc,*.class,*.o,*.obj "when displaying/completing files/directories, ignore these patterns
set title "change the terminal's title
"set visualbell "flash screen instead of beeping
set noerrorbells "don't beep for error MESSAGES (errors still always beep)
"set clipboard=unnamedplus "use X11 clipboard as default
set verbosefile=/dev/null "discard all messages
redir >>/dev/null "redirect messages to null (sort of the same as above line)
let mapleader = "," "you can enter special commands with combinations that start with mapleader
set backupdir=~/.vimbackup,/tmp "where to store backup (~) files
set directory=~/.vimswp,/tmp "where to store swap (.swp) files
set undofile "allow undo across vim restarts
set undodir=~/.vimundo,/tmp "where to store undo (.udf) files
set ruler "show line,column,% of file in bottom line
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>:ccl<CR>
set wildmenu "vim command completion
set wildmode=longest:full,full "vim command completion
set nostartofline "don't position cursor at start of line when switching buffers (as well as other situations)
"load internal matchit plugin/macro
runtime macros/matchit.vim
"auto highlight word under cursor after 500 ms of idle
"augroup auto_highlight
" au!
" au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
"augroup end
"setl updatetime=750
"mappings
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"inoremap <expr> <C-n> pumvisible() ? '<C-n>' : '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
""inoremap <expr> <Nul> pumvisible() \|\| &omnifunc == "" ? "\<C-n>\<Down>" : "\<C-x>\<C-o>\<Down>"
"inoremap <silent> <expr> <Nul> pumvisible() ? '<Down>' : '<C-r>=&omnifunc == "" ? "\<lt>C-n>\<lt>Down>" : "\<lt>C-x>\<lt>C-o>\<lt>Down>"<CR>'
"so you don't have to push and release 'Shift' when typing vim commands
nnoremap ; :
"'j' moves down a row instead of down a line (useful when really long text wraps)
nnoremap j gj
"same as above for 'k'
nnoremap k gk
" redo
nmap U :later 1<CR>
" Auto-indent whole file
nmap <leader>= gg=G``
" Jump to a new line in insert mode
imap <D-CR> <Esc>o
"esc is too far away!
imap kj <Esc>
"copy/cut to OS clipboard in visual/select mode
vmap Y "+y
vmap X "+x
"search for word under cursor
nnoremap <F6> :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
"jump to the last position (:help last-position-jump)
autocmd BufReadPost * if line("'\"") <= line("$") | exe "normal! g`\"" | endif
"or this if you want to restore folds
"autocmd BufWinLeave * mkview
"autocmd BufWinEnter * if &modifiable | silent loadview | endif
"force unix line endings
"autocmd BufWinEnter * set fileformat=unix
"folding
set foldcolumn=4 "width of left column displaying info about folds
set foldlevelstart=1 "automatically fold any folds higher than this level
set fillchars=fold:\
"cause space to open a fold if you are on a line containing a fold, otherwise move right
nnoremap <silent> <Space> @=(foldlevel('.')?'za':'l')<CR>
"create a fold by selecting text and hitting space
vnoremap <Space> zf
"open all folds by hitting ctrl-space
"vnoremap <Nul> zR
"anytime a new buffer is opened set fold method to indent
"augroup vimrc
" au BufReadPre * setlocal foldmethod=syntax
"augroup END
"autocmd BufReadPost * :CollapseAll
"let SimpleFold_use_subfolds = 0
" Searching in files
" Use the Silver Searcher if possible
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor\ --smart-case
endif
"code navigation
"find where method under cursor is called
"nmap <F7> :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR>
"jump to definition of method under cursor
"g<C-]> is part of the tags feature of vim - equivalent of :tjump <symbol
"under cursor> - means jump to definition or popup menu if more than 1 def
"nnoremap <C-b> g<C-]>
"nmap <C-b> :cstag <C-R>=expand("<cword>")<CR><CR>
"acp
let g:juggler_enableAtStartup = 1
let g:juggler_logLevel = 'debug'
let g:juggler_useTagsCompleter = 1
let g:juggler_useCscopeCompleter = 1
let g:juggler_useOmniCompleter = 0
let g:juggler_additionalPathExcludes = ['*/test-ui/reports/*']
let g:acp_enableAtStartup = 0
let g:acp_completeoptPreview = 1
"syntastic
let g:syntastic_go_checkers = ['golint', 'govet']
"vim-expand-region
let g:expand_region_text_objects_ruby = {
\ 'iw' :0,
\ 'iW' :0,
\ 'i"' :0,
\ 'i''':0,
\ 'i]' :1,
\ 'ib' :1,
\ 'iB' :1,
\ 'ir' :1,
\ 'ar' :1,
\ }
"call expand_region#custom_text_objects('ruby', {
" \ 'ir' :1,
" \ 'ar' :1,
" \ })
"command-t
"nnoremap <silent> <C-n> :CommandTTag<CR>
"nnoremap <silent> <C-m> :CommandT<CR>
"let g:CommandTMatchWindowAtTop = 1
"ctrlp
let g:ctrlp_working_path_mode = '0'
let g:ctrlp_map = '<C-@>'
"let g:ctrlp_cmd = 'CtrlPMixed' "careful here, when searching MRU it is across all sessions/historical MRUs
let g:ctrlp_extensions = ['tag']
"let g:ctrlp_custom_ignore = '\v(\.git|\.hg|\.svn|tmp\/|vendor\/bundle|bower_components\/|node_modules\/|app\/components\/|Godeps\/|log\/)'
let g:ctrlp_custom_ignore = '\v(\.git|\.hg|\.svn|tmp\/|vendor\/bundle|bower_components\/|node_modules\/|Godeps\/|log\/)'
"let g:ctrlp_match_func = {'match':'ctrlpmatcher#MatchIt'}
let g:ctrlpmatcher_debug = 0
nnoremap <silent> <C-t> :CtrlPTag<CR>
"nnoremap <silent> <Nul> :CtrlP<CR>
set timeout timeoutlen=1000 ttimeoutlen=100
"set <F13>=[1;5S
set <F13>=O1;5S
nmap <F13> :TagbarToggle<CR>
"taglist
"let g:Tlist_Show_One_File = 1
"let g:Tlist_Close_On_Select = 1
"let g:Tlist_Exit_OnlyWindow = 1
"let g:Tlist_Process_File_Always = 1
"let g:Tlist_Sort_Type = "name"
"let g:Tlist_WinWidth = 60
"let g:tlist_coffee_settings = 'coffee;c:class;f:function;v:variable'
"nnoremap <silent> <F5> :TlistOpen<CR>
"tagbar
let g:tagbar_left = 1
let g:tagbar_autoclose = 1
let g:tagbar_autofocus = 1
let g:tagbar_width = 60
let g:tagbar_sort = 1
let g:tagbar_compact = 1
nnoremap <silent> <F5> :TagbarToggle<CR>
let g:tagbar_type_coffee = {
\ 'ctagstype' : 'coffee',
\ 'kinds' : [
\ 'c:classes',
\ 'm:methods',
\ 'f:functions',
\ 'v:variables',
\ 'f:fields',
\ ]
\ }
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
"showmarks
"let g:showmarks_textupper=">"
"let g:showmarks_textlower=">>"
"hi default ShowMarksHLl ctermfg=white ctermbg=blue cterm=bold guifg=white guibg=blue gui=bold
"hi default ShowMarksHLu ctermfg=white ctermbg=blue cterm=bold guifg=white guibg=blue gui=bold
"hi default ShowMarksHLo ctermfg=white ctermbg=blue cterm=bold guifg=white guibg=blue gui=bold
"hi default ShowMarksHLm ctermfg=white ctermbg=blue cterm=bold guifg=white guibg=blue gui=bold
"vim-bookmarks
let g:bookmark_save_per_working_dir = 1
let g:bookmark_auto_save = 1
let g:bookmark_auto_close = 1
"BufferExplorer
nnoremap <silent> <C-h> :BufExplorer<CR>j
"NERDTree
let g:NERDTreeQuitOnOpen = 1
let g:NERDChristmasTree = 1
let g:NERDTreeWinSize = 48
nnoremap <silent> <F4> :NERDTreeFind<CR>
"NERDCommenter
"have to do these two to prevent the plugin from overriding our '<leader>cc'
"mappings below
nmap <leader>c6 <plug>NERDCommenterComment
xmap <leader>c6 <plug>NERDCommenterComment
",cc to comment a line or selected block
nmap <leader>cc <plug>NERDCommenterAlignLeft
xmap <leader>cc <plug>NERDCommenterAlignLeft
",cu to uncomment a line or selected block - already done natively by NERDCommenter
"cscope
set cscopetag " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set csto=1 " check tags for definition of a symbol before checking cscope
" add cscope db
if filereadable("cscope.out")
cs add cscope.out
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set cscopeverbose " show msg when any other cscope db added
set cscopequickfix=s-,c-,d-,i-,t-,e- "blow away all previous quickfix entries for all types of cscope searches
"jump to next quickfix entry and redisplay the quickfix list
nnoremap <C-j> :cn<CR>:copen<CR>
"jump to previous quickfix entry and redisplay the quickfix list
nnoremap <C-k> :cp<CR>:copen<CR>
"EasyMotion
"move down by lines
vmap <leader>j :<C-U>call EasyMotion#JK(1, 0)<CR>
omap <leader>j :call EasyMotion#JK(0, 0)<CR>
nmap <leader>j :call EasyMotion#JK(0, 0)<CR>
"move up by lines
vmap <leader>k :<C-U>call EasyMotion#JK(1, 1)<CR>
omap <leader>k :call EasyMotion#JK(0, 1)<CR>
nmap <leader>k :call EasyMotion#JK(0, 1)<CR>
"move forward by words
vmap <leader>w :<C-U>call EasyMotion#WB(1, 0)<CR>
omap <leader>w :call EasyMotion#WB(0, 0)<CR>
nmap <leader>w :call EasyMotion#WB(0, 0)<CR>
"move backward by words
vmap <leader>b :<C-U>call EasyMotion#WB(1, 1)<CR>
omap <leader>b :call EasyMotion#WB(0, 1)<CR>
nmap <leader>b :call EasyMotion#WB(0, 1)<CR>
"filetypes
au BufRead,BufNewFile *.jst.ejs set filetype=html
au BufRead,BufNewFile *.jst.str set filetype=html
au BufRead,BufNewFile *.hbs set filetype=html
"language specific stuff
"ruby
"function s:add_global_ruby_cscope()
" if filereadable($HOME . "/.ruby.cscope") && !cscope_connection(2, $HOME . "/.ruby.cscope")
" cscope add ~/.ruby.cscope
" endif
"endfunction
"autocmd FileType ruby,eruby call s:add_global_ruby_cscope()
"autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
"autocmd FileType ruby,eruby set tags=ruby.tags
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby set iskeyword=@,48-57,_,?,!,192-255
"vim
"autocmd FileType vim call Collapse_SetRegexs('^\s*function!\?', '^\s*endfunction\s*$', '^\s*"')
"python
"autocmd FileType python call Collapse_SetRegexs('^\s*def\s', '', '^\s*#')
autocmd FileType python setl ts=4 sts=4 sw=4 et
"function s:add_global_python_cscope()
" if filereadable($HOME . "/.python.cscope") && !cscope_connection(2, $HOME . "/.python.cscope")
" cscope add ~/.python.cscope
" endif
"endfunction
"autocmd FileType python call s:add_global_python_cscope()
"autocmd FileType python set tags=python.tags,~/.python.ctags
autocmd FileType python set omnifunc=pythoncomplete#Complete
"autocmd FileType python nnoremap <silent> <C-F12> :!find /usr/lib/python`python -c 'import sys; print sys.version[:3]'` -name '*.py' -perm -444\| cscope -f ~/.python.cscope -q -i - -b<CR>:cs reset<CR><CR>
"autocmd FileType python nnoremap <silent> <C-F12> :!find /usr/lib/python`python -c 'import sys; print sys.version[:3]'` -name '*.py' -perm -444\| ctags --sort=foldcase -f ~/.python.ctags -L-<CR>
"coffeescript
"autocmd FileType coffee set tags=coffee.tags
"json
"autocmd FileType json autocmd BufWritePre <buffer> %!python -m json.tool
autocmd FileType json autocmd BufWritePre <buffer> %!python -c 'import sys,collections,json;print json.dumps(json.loads(sys.stdin.read(),object_pairs_hook=collections.OrderedDict),sort_keys=False,indent=2,separators=(",", ": "))'
"c/c++
autocmd FileType c setl ts=2 sts=2 sw=2 et
"autocmd FileType c set tags=c.tags
autocmd FileType c set omnifunc=ccomplete#Complete
"go
"if exists("g:did_load_filetypes")
" filetype off
" filetype plugin indent off
"endif
"set runtimepath+=$GOROOT/misc/vim " replace $GOROOT with the output of: go env GOROOT
"filetype plugin indent on
"syntax on
let g:go_fmt_command = "goimports"
let g:go_list_type = "quickfix"
autocmd FileType go highlight clear ExtraWhitespace
autocmd FileType go setl ts=2 sts=2 sw=2 noexpandtab
"autocmd FileType go set tags=.go.tags,~/.go.tags
"autocmd FileType go set tags=.go.tags