forked from johndgiese/dotvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
469 lines (381 loc) · 11 KB
/
Copy pathvimrc
File metadata and controls
469 lines (381 loc) · 11 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
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
" GENERAL SETTINGS
set autoindent
set showmatch
set ruler
set laststatus=2
set backspace=indent,eol,start
set showmode
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
set history=1000
set encoding=utf-8
set noswapfile
set hidden
set number numberwidth=3
set wrap linebreak
set nocompatible
let mapleader = ","
" allow scrolling in vim
set mouse=a
" keep vim from prompting when a file changes in the background, just re-read
" it; this is a contencious setting, make sure you know what it does
set autoread
" DIRECTORIES
if has('win32') || has('win64')
let g:DV=$HOME.'\vimfiles'
else
let g:DV=$HOME.'/.vim'
endif
let g:DV=expand(g:DV)
" backup
let &backupdir=g:DV."/tmp/backup"
if !isdirectory(g:DV."/tmp/backup")
call mkdir(g:DV."/tmp/backup", 'p', 0755)
endif
" tags
let &tags=g:DV."/tmp/tags/"
if !isdirectory(g:DV."/tmp/tags")
call mkdir(g:DV."/tmp/tags", 'p', 0755)
endif
" PLUGINS
" Set everything so vundle can load
autocmd!
filetype off
let &rtp.=','.g:DV.'/bundle/vundle'
call vundle#rc(g:DV.'/bundle/')
Bundle 'gmarik/vundle'
" Use Git inside vim easily
Bundle 'tpope/vim-fugitive.git'
Bundle 'tpope/vim-git.git'
nnoremap dp dp]c
nnoremap do do]c
" Move back and forth through commits while staying on the same line
nnoremap <A-right> :call GlogForward()<CR>
nnoremap <A-left> :call GlogBackward()<CR>
function! GlogForward()
let l:line=line('.')
try
cnext
catch /^Vim\%((\a\+)\)\=:E553/
echo 'Already at the newest version'
endtry
call setpos('.', [0, l:line, 0, 0])
endfunction
function! GlogBackward()
let l:line=line('.')
try
cprev
catch /^Vim\%((\a\+)\)\=:E553/
echo 'Already at the oldest version'
endtry
call setpos('.', [0, l:line, 0, 0])
endfunction
" Commenting tools
Bundle 'scrooloose/nerdcommenter.git'
" Lets you deal with braket pairs etc.
Bundle 'tpope/vim-surround.git'
" Align code usint :Tab/someregexp
Bundle 'godlygeek/tabular.git'
" Autocomplete
Bundle 'Valloric/YouCompleteMe'
let g:ycm_key_list_previous_completion=['<Up>']
let g:ycm_key_invoke_completion = '<C-Tab>'
let g:ycm_use_ultisnips_completer = 1
" Better javascript indenting etc.
Bundle 'pangloss/vim-javascript.git'
" Better javascript syntax
Bundle 'jelera/vim-javascript-syntax.git'
" Javascript autocompletion and code navigation
"Bundle 'marijnh/tern_for_vim'
" Node.js tools
Bundle 'moll/vim-node'
" Arduino syntax highlighting
Bundle "sudar/vim-arduino-syntax"
" extended matching with %
Bundle 'edsono/vim-matchit.git'
" make more commands work with repate
Bundle 'tpope/vim-repeat'
" handle word variants
Bundle 'tpope/vim-abolish'
" visual selection search with # and *
Bundle 'nelstrom/vim-visual-star-search'
" various mappings related to pairs
Bundle 'tpope/vim-unimpaired.git'
" colors can be highlighed using <leader>c
Bundle 'chrisbra/color_highlight'
nmap <leader>c <Plug>Colorizer<CR>
" less syntax highlighting
Bundle 'groenewege/vim-less'
" File browsing
Bundle 'scrooloose/nerdtree.git'
noremap <silent> <leader>1 :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\~$', '\.pyc']
" Ack search integration
Bundle 'mileszs/ack.vim.git'
" Add Cdo and Ldo (similar to argdo but for the quickfix list)
Bundle 'Peeja/vim-cdo'
" Toggle quickfix and localist
Bundle 'milkypostman/vim-togglelist'
" Ctag viewer
Bundle 'majutsushi/tagbar.git'
let g:tagbar_iconchars = ['+', '-']
noremap <silent> <leader>2 :TagbarToggle<CR>
" Nice buffer browsers/switcher
Bundle 'corntrace/bufexplorer'
noremap <silent> <leader>3 :BufExplorer<CR>
let g:bufExplorerDefaultHelp=0
" Vim sugar for unix shell commands that need it
Bundle 'tpope/vim-eunuch.git'
" branching undo is new in vim 7.3
if v:version > 702
let &undodir=g:DV."/tmp/undo"
if !isdirectory(g:DV."/tmp/undo")
call mkdir(g:DV."/tmp/undo", 'p', 0755)
endif
set undofile
" Graphical interface for the vim's branching undo stuff
Bundle 'sjl/gundo.vim.git'
nnoremap <silent> <leader>4 :GundoToggle<CR>
let g:gundo_right = 1
let g:gundo_help = 0
endif
" Python tab-completeion with jedi
"Bundle 'davidhalter/jedi-vim'
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#goto_definitions_command = "gd"
let g:jedi#popup_on_dot = 0
let g:jedi#show_call_signatures = 0
" A better status line
Bundle 'Lokaltog/vim-powerline.git'
let g:Powerline_stl_path_style='relative'
let g:Powerline_symbols='compatible'
" A fuzzy file finder-- really great just press CTRL-P!
Bundle 'kien/ctrlp.vim.git'
let g:ctrlp_working_path_mode = 'ar'
let g:ctrlp_extensions = ['mixed']
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_custom_ignore = {
\ 'file': '\v\.(pyc)$',
\ 'dir': '\v[\/](env|collected_static)$',
\ }
" Snippets Plugin
" Note: snipmate has more snippets, but fewer features---I think ultisnips
" will win out pretty soon
Bundle "SirVer/ultisnips"
set runtimepath+=~/.vim/ultisnips_rep
let g:UltiSnipsExpandTrigger="<c-space>"
let g:UltiSnipsListSnippets="<c-s-space>"
let g:UltiSnipsJumpForwardTrigger="<c-space>"
let g:UltiSnipsJumpBackwardTrigger="<c-s-space>"
nnoremap <leader>u :UltiSnipsEdit<CR>
" Syntax highlighting interface
Bundle 'scrooloose/syntastic.git'
let g:locliststate=1
let g:syntastic_enable_ballons=0
let g:syntastic_auto_loc_list=1
let g:syntastic_enable_signs=0
let g:syntastic_enable_auto_jump=1
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['python', 'javascript'] }
let g:syntastic_python_checkers=['flake8', 'pylint']
let g:syntastic_python_pylint_args = "--errors-only"
let g:syntastic_javascript_checkers=['jshint', 'jslint']
let g:syntastic_enable_highlighting=0
let g:syntastic_on=0
function! SyntasticToggle()
let g:syntastic_enable_highlighting=g:syntastic_on
SyntasticCheck
if g:syntastic_on
lclose
end
let g:syntastic_on=!g:syntastic_on
endfunction
nnoremap <silent> <leader>e :call SyntasticToggle()<CR>
" OTHER GOOD PLUGINS
" Uncomment and run BundleInstall! to use
" Conque Shell
" Bundle 'vim-scripts/Conque-Shell'
" The solarized color theme
" Bundle 'altercation/vim-colors-solarized'
" let g:solarized_termcolors=256
" Save the vim state and reload when you come back
" Bundle 'xolox/vim-session.git'
" A nice indicator for git
" Bundle 'airblade/vim-gitgutter'
" Put in closing brackets automatically
" Bundle 'Townk/vim-autoclose.git'
" GOOGLE SEARCH
function! GoogleSearch()
let searchterm = getreg("g")
silent! exec "silent! !chrome \"http://google.com/search?q=" . searchterm . "\" &"
endfunction
vnoremap <leader>g "gy<Esc>:call GoogleSearch()<CR>
" MAPPINGS
" better <ESC> (to go back to normal mode from insert mode)
inoremap jk <ESC>
inoremap <ESC> <nop>
" switch semi-colon and colon
nnoremap ; :
vnoremap ; :
nnoremap : ;
vnoremap : ;
" insert the very magic reg-ex mode every time
set hlsearch incsearch
nnoremap / /\v
nnoremap ? ?\v
nnoremap <silent> <leader>/ :noh<CR>
" set paste toggle
set pastetoggle=<leader>p
" set make program shortcut
nnoremap <leader>5 :call Make()<CR>
vnoremap <leader>5 :call Make()<CR>
function! Make()
make
if !g:quickfix_open
if (len(getqflist()) > 1)
copen
let g:quickfix_open=1
end
end
endfunction
" toggle fugivite status
let g:gstatus_open=0
function! GStatusToggle()
if g:gstatus_open
try
bdelete index
let g:gstatus_open=0
catch
Gstatus
let g:gstatus_open=1
endtry
else
Gstatus
let g:gstatus_open=1
end
endfunction
nnoremap <silent> <leader>6 :call GStatusToggle()<CR>
nnoremap <A-]> :cnext<CR>
nnoremap <A-[> :cprev<CR>
" Remap block-visual mode to alt-V, and set paste-from-clipboard to C-v
nnoremap <A-v> <C-v>
"nnoremap <C-v> "+gp
"inoremap <C-v> <ESC>"+gpi
"vnoremap <C-v> d"+p
vnoremap <C-c> "+y
vnoremap <C-x> "+ygvd
" Move between editor lines (instead of actual lines) when holding CTRL
vnoremap j gj
vnoremap k gk
vnoremap $ g$
vnoremap ^ g^
vnoremap 0 g0
nnoremap j gj
nnoremap k gk
nnoremap $ g$
nnoremap ^ g^
nnoremap 0 g0
" jumping to definitions
" goto definition
nnoremap gd <C-]>zz
" go back
nnoremap gb <C-t>
" see uses
nnoremap gu vawy:tselect <C-r>0<CR>
" making vim command line more like bash
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>
" buffer switching
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> ]B :blast<CR>
" window switching
" moving using M-direction
" open new windows ugin M-S-direction
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Highlight whitespace with <leader>w, and remove with <leader>W
nnoremap <leader>w :/\s\+$<CR>
nnoremap <leader>W :%s/\s\+$//e<CR><silent>:noh<CR>
" SPELLING
" toggle spell checking
nnoremap <silent> <leader>s :set spell!<CR>
" correct the current word and move to the next one using ,S
nnoremap <silent> <leader>S 1z=]s
set spelllang=en_us " Set region to US English
let &spellfile=g:DV."/spell/en.latin1.add"
" EDIT CUSTOMIZATION
" Start editing the vimrc in a new buffer
nnoremap <leader>v :call Edit_vimrc()<CR>
function! Edit_vimrc()
exe 'edit ' . g:DV . '/vimrc'
endfunction
" Edit your colorscheme on the fly!
nnoremap <leader>o :call Edit_colorscheme()<CR>
function! Edit_colorscheme()
exe 'edit ' . g:DV . '/colors/betterblack.vim'
endfunction
" See what syntax groups are under the cursor
nnoremap <leader>O :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunction
if !exists("autocommands_loaded")
let autocommands_loaded=1
" Rerun vimrc upon editing
autocmd bufwritepost vimrc source %
" update the colorscheme upon saving
autocmd bufwritepost betterblack.vim :colorscheme betterblack
endif
" NETWORK
" Disable matching parenthesise when on a network file
autocmd BufReadPre //* :NoMatchParen
" WEB DEVELOPMENT
" better html/javascript syntax/indenting (see javascript plugin)
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" General web stuff
au FileType htmldjango set ft=htmldjango.html
" Cscope stuff
if has("cscope")
set csprg=/usr/local/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" OS DEPENDENT STUFF
if has('win32') || has('win64')
set guifont=Consolas:h10
elseif has('mac')
let macvim_skip_cmd_opt_movement = 1
let macvim_skip_colorscheme = 1
let macvim_hig_shift_movement = 1
set macmeta
set noantialias
set guifont=Monaco:h10
else
set guifont=CodingFontTobi\ 12
endif
syntax enable
filetype plugin indent on
set t_Co=256
colorscheme betterblack