This repository has been archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
403 lines (336 loc) · 11 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
"
" ~/.vimrc (https://github.com/otaviof/vim_confs)
"
set nocompatible
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs
set nobackup
set noswapfile
let apleader= ','
let leader=','
let localleader=","
let mapleader=","
let maplocalleader=','
" Pathogen load
filetype off
call pathogen#infect()
call pathogen#helptags()
syntax on
filetype plugin on
filetype indent on
if has("autocmd")
source ~/.vim/augroup.vim
endif
source ~/.vim/set_globals.vim
runtime macros/matchit.vim
" ----------------------------------------------------------------------------
" -- Methods and special maps for them:
" ----------------------------------------------------------------------------
""" Returns Current Directory
function! CurDir()
let curdir = substitute( getcwd(), $HOME, "~", "g" )
return curdir
endfunction
""" Perl Completion Behavior
function! PerlCompletionBehavior()
let behavs = {'perl':[]}
call add(behavs.perl, {
\ 'command' : "\<D-/>",
\ 'pattern' : printf('\w->\k\{%d,}$',1),
\ 'repeat' : 0,
\ })
return behavs
endf
""" Perl function declaration
function! GotoSub(subname)
let files = []
" find paths to modules with that sub
let paths = split(system("ack --perl -l 'sub\\s+".a:subname."' lib t/lib"), "\n")
if empty(paths)
echomsg("Subroutine '".a:subname."' not found")
else
let file = PickFromList('file', paths)
execute "edit +1 " . file
" jump to where that sub is defined
execute "/sub\\s\\+" . a:subname . "\\>"
endif
endfunction
function! PickFromList( name, list, ... )
let forcelist = a:0 && a:1 ? 1 : 0
if 1 == len(a:list) && !forcelist
let choice = 0
else
let lines = [ 'Choose a ' . a:name . ':' ]
\ + map(range(1, len(a:list)), 'v:val .": ". a:list[v:val - 1]')
let choice = inputlist(lines)
if choice > 0 && choice <= len(a:list)
let choice = choice - 1
else
let choice = choice - 1
endif
end
return a:list[choice]
endfunction
noremap <Localleader>gm :call GotoSub(expand('<cword>'))<cr>
""" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
" map <silent> <D-E> :call ToggleVExplorer()<CR>
" ----------------------------------------------------------------------------
" -- Mappings:
" ----------------------------------------------------------------------------
" yank (copy) full path of file
nmap <leader>cp :let @" = expand("%")
" no macro recorder
nnoremap q <NOP>
" send paste (p) register to blackhole (_)
vnoremap <leader>p "_dP
" Alloy's file drawer (Textmate's alike)
" map <silent><D-E> :macaction toggleDrawer:<CR>
" map <silent><D-M-e> :macaction selectInDrawer:<CR>
" TaskList Plugin
map <leader>j <Plug>TaskList
" Ctrl-P
let g:ctrlp_map = '<D-T>'
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
set wildignore+=.git\*,.hg\*,.svn\* " for Windows
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
" Perl Deparse
" nnoremap <silent> <Localleader>d :.!perl -MO=Deparse 2>/dev/null<cr>
" vnoremap <silent> <Localleader>d :!perl -MO=Deparse 2>/dev/null<cr>
" JSON tidy-up
noremap <leader>jt mz:%!json_xs -f json -t json-pretty<CR>'z:delmarks z<CR>
" Java Completion
" inoremap <buffer> <C-X><C-U> <C-X><C-U><C-P>
" inoremap <buffer> <C-S-Space> <C-X><C-U><C-P>
" Spelling checking for pt_BR and en_US
map <Localleader>s :runtime ~/.vim/spell/<CR>:set spl=pt,en spell<CR>
" UTF8 conversion
nmap <Localleader>utf8 !recode -q ISO-8859-1..utf-8
" Shortcuts for Tabs (Command on OS X)
if has("gui_mac") || has("gui_macvim")
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
map <D-0> 10g
endif
" Display margin
map <Localleader>m <ESC>:match rightMargin /.\%>79v/<CR>
map <Localleader>M <ESC>:match rightMargin <CR>
" NERDTree
let NERDTreeHighlightCursorline=1
let NERDTreeShowBookmarks=0
let NERDChristmasTree=1
let NERDTreeAutoCenter=1
let NERDTreeWinPos='right'
let NERDTreeIgnore=['\.pyc$', '\.o$', '\~$']
map <Localleader>n :execute 'NERDTreeToggle'<CR>
nnoremap <Localleader>f :execute 'NERDTreeFind'<CR>
nnoremap <Localleader>N :execute 'NERDTreeFind'<CR>
" TagBar
nmap <F6> :TagbarToggle<CR>
let g:tagbar_left = 1
let g:tagbar_expand = 1
let g:tagbar_width = 28
let g:tagbar_compact = 1
let g:tagbar_iconchars = ['▸', '▾']
" ----------------------------------------------------------------------------
" -- Plugins Options:
" ----------------------------------------------------------------------------
" Perl Options
let g:def_perl_comp_bfunction=1
let g:def_perl_comp_packagen=1
let perl_extended_vars=1
let perl_include_pod=1
let perl_nofold_packages=1
let perl_nofold_subs=0
let perl_string_as_statement=1
let perl_want_scope_in_variables=1
let perl_perltags=0
" Python Options
let python_highlight_all=1
" Tag List Options
let tlist_auto_highlight_tag=1
let tlist_compact_format=0
let tlist_ctags_cmd='/usr/bin/ctags'
let tlist_process_file_always=1
let tlist_show_one_file=0
let tlist_winwidth=35
let tlist_perl_settings='perl;u:use;p:package;r:role;e:extends;c:c+onstant;a:attribute;s:subroutine;l:label'
" Delimate options
let b:delimitMate="(:),[:],{:},<:>"
let b:delimitMate_autoclose=1
let b:delimitMate_expand_cr=1
let b:delimitMate_expand_space=1
let b:delimitMate_matchpairs="(:),[:],{:},<:>"
let b:delimitMate_quotes="\" ' `"
let b:delimitMate_visual_leader="f"
let delimitMate_nesting_quotes = ['"','`']
" NetRW options
let g:netrw_browse_split = 2
let g:netrw_altv = 1
let g:netrw_fastbrowse = 2
let g:netrw_keepdir = 0
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_retmap = 1
let g:netrw_silent = 1
let g:netrw_special_syntax = 1
let g:netrw_menu = 1
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'
" XMLEDIT
let xml_tag_completion_map="<C-l>"
let xml_tag_syntax_prefixes='html\|xml'
let xml_use_xhtml=1
" Not loading some menus
let BASH_LoadMenus='no'
let C_LoadMenus='no'
let Perl_LoadMenus='no'
" FIXME Indent Guide
let g:indent_guides_hex_color_pattern=""
" Textile default browser
let g:TextileBrowser="Google Chrome"
" Key for run python code
let g:pymode_folding = 0
let g:pymode_run = 0
let g:pymode_rope_vim_completion=1
let g:pymode_rope_extended_complete=1
let g:pymode_lint_ignore = "E501,W404,W802,W0401,W0404"
let g:pymode_rope_vim_completion = 1
let g:pymode_rope_guess_project = 1
let g:pymode_rope_always_show_complete_menu = 0
" tagbar for Golang
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'
\ }
" ----------------------------------------------------------------------------
" -- neocomplcache
" ----------------------------------------------------------------------------
" Disable AutoComplPop. Comment out this line if AutoComplPop is not installed.
let g:acp_enableAtStartup = 1
" Launches neocomplcache automatically on vim startup.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underscore completion.
let g:neocomplcache_enable_underbar_completion = 1
" Sets minimum char length of syntax keyword.
let g:neocomplcache_min_syntax_length = 3
" buffer file name pattern that locks neocomplcache. e.g. ku.vim or fuzzyfinder
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Define file-type dependent dictionaries.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword, for minor languages
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
" imap <C-k> <Plug>(neocomplcache_snippets_expand)
" smap <C-k> <Plug>(neocomplcache_snippets_expand)
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
" not showing scratch preview
" http://stackoverflow.com/questions/13611198/vim-neocomplcache-disable-usage-prompt
set completeopt-=preview
" OnSyntaxChange: disabling AutoComplPop for comments
" http://stackoverflow.com/questions/10723499/how-to-disable-autocomplpop-completions-in-comments
call OnSyntaxChange#Install('Comment', '^Comment$', 0, 'i')
autocmd User SyntaxCommentEnterI silent! AcpLock
autocmd User SyntaxCommentLeaveI silent! AcpUnlock
" Plum colorscheme
let g:plum_cursorline_highlight_only_linenr = 0
let g:plum_set_bg_at_start = 0
" Airline
let g:airline_enable_branch = 1
let g:airline_powerline_fonts = 0
let g:airline_detect_modified = 1
let g:airline_enable_syntastic = 0
let g:airline_branch_prefix = '⭠ '
" let g:airline_left_sep = '»'
" let g:airline_left_sep = '≫'
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '⮁'
let g:airline_linecolumn_prefix = '¶ '
let g:airline_paste_symbol = 'Þ'
let g:airline_readonly_symbol = '⭤'
" let g:airline_right_sep = '«'
" let g:airline_right_sep = '≪'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '⮃'
let g:airline_detect_whitespace = 0
" ----------------------------------------------------------------------------
" -- Git bindings:
" ----------------------------------------------------------------------------
nnoremap ,gd :GitDiff<Enter>
nnoremap ,gD :GitDiff --cached<Enter>
nnoremap ,gs :GitStatus<Enter>
nnoremap ,gl :GitLog<Enter>
nnoremap ,ga :GitAdd<Enter>
nnoremap ,gA :GitAdd <cfile><Enter>
nnoremap ,gc :GitCommit<Enter>
nnoremap ,gp :GitPullRebase<Enter>
nnoremap ,gP :GitPush<Enter>
" EOF