forked from avelino/.vimrc
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
470 lines (368 loc) · 12.2 KB
/
Copy pathvimrc
File metadata and controls
470 lines (368 loc) · 12.2 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
470
"*****************************************************************************
"" Pathgen Load
"*****************************************************************************
"{{{
" Load pathgen
runtime! autoload/pathogen.vim
if exists('g:loaded_pathogen')
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundle'))
end
"}}}
"*****************************************************************************
" Basic Setup
"*****************************************************************************
"{{{
" Unleash all VIM power
set nocompatible
" Fix backspace indent
set backspace=indent,eol,start
filetype on
filetype plugin indent on
" Better modes. Remeber where we are, support yankring
set viminfo=!,'100,\"100,:20,<50,s10,h,n~/.viminfo
" Tabs. May be overriten by autocmd rules
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab
" Enable hidden buffers
set hidden
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Tab completion
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,.pyc
" Remember last location in file
if has("autocmd")
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" GREP
set grepprg=ack
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set bomb
set ttyfast
set binary
"Directories for swp files
set nobackup
set nowritebackup
set noswapfile
set sh=/bin/sh
set nocompatible
set fileformats=unix,dos,mac
set backspace=indent,eol,start
set showcmd
"}}}
"*****************************************************************************
" Visual Settigns
"*****************************************************************************
"{{{
" colorscheme, fonts, menus and etc
set background=dark
syntax on
set ruler
set number
" Menus I like :-)
" This must happen before the syntax system is enabled
aunmenu Help.
aunmenu Window.
let no_buffers_menu=1
set mousemodel=popup
highlight BadWhitespace ctermbg=red guibg=red
colorscheme molokai
set t_Co=256
set cursorline
set guioptions=egmrt
set gfn=Monospace\ 8
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
endif
" Disable the pydoc preview window for the omni completion
set completeopt-=preview
" Disable the blinking cursor.
set gcr=a:blinkon0
set scrolloff=3
" Status bar
set laststatus=2
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
" Include user's local vim config
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\ %{fugitive#statusline()}
"}}}
"*****************************************************************************
" Abbreviations
"*****************************************************************************
"{{{
" no one is really happy until you have this shortcuts
cab W! w!
cab Q! q!
cab Wq wq
cab Wa wa
cab wQ wq
cab WQ wq
cab W w
cab Q q
"}}}
"*****************************************************************************
" Variables
"*****************************************************************************
"{{{
" Conf Avelino
let g:snips_author = "Thiago Avelino"
" python support
" --------------
" don't highlight exceptions and builtins. I love to override them in local
" scopes and it sucks ass if it's highlighted then. And for exceptions I
" don't really want to have different colors for my own exceptions ;-)
let python_highlight_all=1
let python_highlight_exceptions=0
let python_highlight_builtins=0
let html_no_rendering=1
let javascript_enable_domhtmlcss=1
let c_no_curly_error=1
let g:closetag_default_xml=1
let g:sparkupNextMapping='<c-l>'
" NERDTree configuration
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$']
let NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let NERDTreeShowBookmarks=1
" Command-T configuration
let g:CommandTMaxHeight=20
" FindFile
let g:FindFileIgnore = ['*.o', '*.pyc', '*.py~', '*.obj', '.git', '*.rbc', '*/tmp/*']
" miniBuf
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" Powerline
let g:Powerline_symbols = 'compatible'
" Flake8
let g:flake8_builtins="_,apply"
let g:flake8_ignore="E501,W293"
let g:flake8_max_line_length=72
let g:pyflakes_use_quickfix = 0
"}}}
"*****************************************************************************
" Function
"*****************************************************************************
"{{{
fun! MatchCaseTag()
let ic = &ic
set noic
try
exe 'tjump ' . expand('')
finally
let &ic = ic
endtry
endfun
function s:setupWrapping()
set wrap
set wm=2
set textwidth=72
endfunction
function s:setupMarkup()
call s:setupWrapping()
noremap <buffer> <Leader>p :Mm <CR>
endfunction
" GUI Tab settings
function! GuiTabLabel()
let label = ''
let buflist = tabpagebuflist(v:lnum)
if exists('t:title')
let label .= t:title . ' '
endif
let label .= '[' . bufname(buflist[tabpagewinnr(v:lnum) - 1]) . ']'
for bufnr in buflist
if getbufvar(bufnr, '&modified')
let label .= '+'
break
endif
endfor
return label
endfunction
set guitablabel=%{GuiTabLabel()}
" Removes trailing spaces
function TrimWhiteSpace()
let @*=line(".")
%s/\s*$//e
''
:endfunction
"}}}
"*****************************************************************************
" Autocmd Rules
"*****************************************************************************
"{{{
" Some minor or more generic autocmd rules
" The PC is fast enough, do syntax highlight syncing from start
autocmd BufEnter * :syntax sync fromstart
" Remember cursor position
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" less comprez
autocmd BufNewFile,BufRead *.less set filetype=less
if has("gui_running")
autocmd BufWritePre * :call TrimWhiteSpace()
endif
" txt
au BufRead,BufNewFile *.txt call s:setupWrapping()
" make use real tabs
au FileType make set noexpandtab
"********** Python
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=110
\ formatoptions+=croq softtabstop=4 smartindent
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
autocmd FileType pyrex setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
\smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
autocmd BufRead,BufNewFile *.py,*pyw set shiftwidth=4
autocmd BufRead,BufNewFile *.py,*.pyw set expandtab
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
autocmd BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
autocmd BufRead,BufNewFile *.py,*.pyw match BadWhitespace /\s\+$/
autocmd BufNewFile *.py,*.pyw set fileformat=unix
autocmd BufWritePre *.py,*.pyw normal m`:%s/\s\+$//e``
autocmd BufRead *.py,*.pyw set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufNewFile,BufRead *.py_tmpl,*.cover setlocal ft=python
" code completion
autocmd FileType python set omnifunc=pythoncomplete#Complete
"********** Go
autocmd BufNewFile,BufRead *.go setlocal ft=go
autocmd FileType go setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
"********** PHP
autocmd FileType php setlocal shiftwidth=4 tabstop=8 softtabstop=4 expandtab
"********** Verilog
autocmd FileType verilog setlocal expandtab shiftwidth=2 tabstop=8 softtabstop=2
"********** HTML
autocmd BufNewFile,BufRead *.mako,*.mak,*.jinja2 setlocal ft=html
autocmd FileType html,xhtml,xml,htmldjango,htmljinja,londonhtml,eruby,mako,haml,daml,css,tmpl setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType html,htmldjango,htmljinja,londonhtml,eruby,mako,haml,daml let b:closetag_html_style=1
autocmd FileType html,xhtml,xml,htmldjango,htmljinja,londonhtml,eruby,mako,haml,daml source ~/.vim/bundle/closetag/plugin/closetag.vim
" code completion
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"********** C/Obj-C/C++
autocmd FileType c setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab colorcolumn=79
autocmd FileType cpp setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab colorcolumn=79
autocmd FileType objc setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab colorcolumn=79
"********** vim
autocmd FileType vim setlocal expandtab shiftwidth=2 tabstop=8 softtabstop=2
autocmd FileType vim setlocal foldenable foldmethod=marker
"********** Javascript
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2 colorcolumn=79
autocmd BufNewFile,BufRead *.json setlocal ft=javascript
" code completion
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"********** Cmake
autocmd BufNewFile,BufRead CMakeLists.txt setlocal ft=cmake
"********** Ruby
" Thorfile, Rakefile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Thorfile,config.ru} set ft=ruby
"********** Markdown
" md, markdown, and mk are markdown and define buffer-local preview
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
"********** Markdown
au BufNewFile,BufRead *.dartset filetype=dart shiftwidth=2 expandtab
"}}}
"*****************************************************************************
" Mappings
"*****************************************************************************
"{{{
" Python Execution
noremap <C-K> :!python<CR>
noremap <C-L> :!python %<CR>
" Split Screen
noremap <Leader>h :split<CR>
noremap <Leader>v :vsplit<CR>
" Git
noremap <Leader>ga :!git add .<CR>
noremap <Leader>gc :!git commit -m '<C-R>="'"<CR>
noremap <Leader>gsh :!git push<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
" ConqueTerm Shortcut
noremap <Leader>sh :ConqueTerm bash --login<CR>
" Paste to DPaste: http://dpaste.com/
noremap <Leader>p :Dpaste<CR>
" NerdTree shortcuts
noremap <Leader>n :NERDTreeToggle<CR>
noremap <Plug> :NERDTreeToggle<CR>
nnoremap <leader>d :NERDTreeToggle<CR>
noremap <F3> :NERDTreeToggle<CR>
" ZoomWin configuration
noremap <Leader>z :ZoomWin<CR>
" BufExplorer configuration
nnoremap <leader>b :BufExplorer<cr>
" Tabs shortcuts
noremap th :tabnext<CR>
noremap t] :tabnext<CR>
noremap tl :tabprev<CR>
noremap t[ :tabprev<CR>
noremap tn :tabnew<CR>
noremap tc :tabclose<CR>
noremap td :tabclose<CR>
" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <Leader>t
noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" Bubble single lines
nnoremap <C-Up> [e
nnoremap <C-Down> ]e
" Bubble multiple lines
vnoremap <C-Up> [egv
vnoremap <C-Down> ]egv
" try to make possible to navigate within lines of wrapped lines
nmap <Down> gj
nmap <Up> gk
" Gundo Toggler
nnoremap <Leader>u :GundoToggle<CR>
noremap <leader>c :GundoToggle<CR>
" Tag Code Navigation
nnoremap <Leader>f :TagbarToggle<CR>
" Find file
nnoremap <C-f> :FF<CR>
nnoremap <C-s> :FS<CR>
nnoremap <C-c> :FC .<CR>
" Remove trailing whitespace on <leader>S
nnoremap <leader>:call TrimWhiteSpace()<cr>:let @/=''<CR>
" Rope
noremap <leader>j :RopeGotoDefinition<CR>
noremap <leader>r :RopeRename<CR>
" Grep
noremap <leader>g :Ack <C-R>=""<CR>
noremap <leader>b :b <C-R>=""<CR>
" Copy
noremap YY "+y<CR>
" Paste
noremap P "+gP<CR>
" Cut
noremap XX "+x<CR>
" TODO: Take a look at this
nnoremap :call MatchCaseTag()
"}}}