-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
537 lines (424 loc) · 16.1 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
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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
scriptencoding utf-8
set nocompatible
" NEOBUNDLE {{{ ===============================================================
filetype off " Turn off filetype plugins before bundles init
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
let g:neobundle#types#git#clone_depth = 1
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
" BUNDLES (plugins administrated by NeoBundle) {{{
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundle 'Shougo/unite.vim'
if has('lua')
NeoBundle 'Shougo/neocomplete'
else
NeoBundle 'Shougo/neocomplcache'
endif
NeoBundle 'Shougo/neosnippet'
" NeoBundle 'Shougo/neosnippet-snippets'
" NeoBundle 'honza/snipmate-snippets'
NeoBundle 'tpope/vim-fugitive'
NeoBundleLazy 'gregsexton/gitv', {'depends':['tpope/vim-fugitive'],
\ 'autoload':{'commands':'Gitv'}}
NeoBundle 'Shougo/vimshell'
NeoBundle 'Shougo/neomru.vim'
NeoBundle 'Shougo/vimfiler'
NeoBundle 'jpalardy/vim-slime'
NeoBundle 'Raimondi/delimitMate'
" NeoBundle 'tomtom/tcomment_vim'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'tpope/vim-endwise'
NeoBundle 'tpope/vim-repeat'
" NeoBundle 'tpope/vim-sleuth'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-unimpaired'
" NeoBundle 'vim-scripts/vcscommand.vim'
NeoBundle 'vim-scripts/tlib'
NeoBundle 'AndrewRadev/splitjoin.vim'
NeoBundleLazy 'othree/html5.vim', { 'autoload': { 'filetypes': ['html', 'css'] } }
NeoBundle 'gregsexton/MatchTag'
" NeoBundle 'skammer/vim-css-color'
NeoBundle 'hail2u/vim-css3-syntax'
NeoBundle 'ignovak/vim-web-indent'
" NeoBundle 'walm/jshint.vim'
NeoBundle 'ignovak/vim-translator'
NeoBundle 'ConradIrwin/vim-bracketed-paste'
" NeoBundle 'ujihisa/unite-colorscheme'
" NeoBundle 'vim-speeddating'
" HTML/HAML
" NeoBundle 'hokaccha/vim-html5validator'
" CSS/LESS
" JavaScript
" NeoBundle 'pangloss/vim-javascript'
" NeoBundle 'itspriddle/vim-jquery'
NeoBundle 'wavded/vim-stylus'
" JSON
" NeoBundle 'leshill/vim-json'
" NeoBundle 'tpope/vim-rails'
" NeoBundle 'tpope/vim-haml'
" NeoBundle 'kchmck/vim-coffee-script'
" NeoBundle 'klen/vim-jsmode'
" NeoBundle 'mattn/gist-vim'
NeoBundle 'vim-scripts/closetag.vim'
NeoBundle 'https://www.vim.org/scripts/download_script.php?src_id=4316',
\ { 'type__filename' : 'python.vim', 'script_type' : 'indent' }
NeoBundle 'editorconfig/editorconfig-vim'
" NeoBundle 'davidhalter/jedi-vim'
" END BUNDLES }}}
call neobundle#end()
filetype plugin indent on
NeoBundleCheck
" }}}
syntax on
" General options
set exrc secure " Enable per-directory .vimrc files and disable unsafe commands in them
" Buffer options
set hidden " hide buffers when they are abandoned
set autoread " auto reload changed files
" Display options
set title " show file name in window title
set novisualbell " mute error bell
set list
set listchars=tab:⇥\ ,trail:·,extends:⋯,precedes:⋯,nbsp:~
set linebreak " break lines by words
set scrolljump=5
set sidescroll=4
set sidescrolloff=10
set showcmd
set whichwrap=b,s,<,>,[,],l,h
set completeopt=menu,preview
set infercase
set ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
set ttyfast " Optimize for fast terminal connections
set shortmess=atI " Don’t show the intro message when starting Vim
set nostartofline
set wrap
" Tab options
set autoindent " copy indent from previous line
set smartindent " enable nice indent
set expandtab " tab with spaces
set smarttab " indent using shiftwidth"
set shiftwidth=4 " number of spaces to use for each step of indent
set tabstop=4
set softtabstop=4 " tab like 4 spaces
set shiftround " drop unused spaces
" Search options
set gdefault " Add the g flag to search/replace by default
set hlsearch " Highlight search results
set ignorecase " Ignore case in search patterns
set smartcase " Override the 'ignorecase' option if the search pattern contains upper case characters
set incsearch " While typing a search command, show where the pattern
set history=1000
nnoremap <silent> <cr> :nohlsearch<cr><cr>
" Matching characters
set showmatch " Show matching brackets
set matchpairs+=<:> " Make < and > match as well
" Localization
set langmenu=none " Always use english menu
set keymap=russian-jcukenwin " Alternative keymap
highlight lCursor guifg=NONE guibg=Cyan
set iminsert=0 " English by default
set imsearch=-1 " Search keymap from insert mode
set spell
set spelllang=en " Languages
set encoding=utf-8 " Default encoding
set fileencodings=utf-8,cp1251,koi8-r,cp866
set termencoding=utf-8
set fileformat=unix
" Wildmenu
set wildmenu " use wildmenu ...
set wildcharm=<TAB>
set wildignore+=*.pyc " ignore file pattern
set wildignore+=*.be.*,*.kk.*,*.tt.*,*.uk.*
" Folding
if has('folding')
set foldmethod=indent
set foldlevel=99
endif
" Edit
set backspace=indent,eol,start " Allow backspace to remove indents, newlines and old tex"
" set virtualedit=block
set pastetoggle=<leader>p
set nobackup
set nowritebackup
set noswapfile
set noeol
set diffopt=filler
set diffopt+=vertical
set diffopt+=iwhite
augroup vimrc
autocmd!
autocmd FileType vim setlocal sw=2
autocmd FileType vim setlocal ts=2
autocmd FileType vim setlocal sts=2
autocmd FileType vim nnoremap <leader>x 0y$:<c-r>"<cr>
" Auto reload vim settings
autocmd BufWritePost *.vim source $MYVIMRC
autocmd BufWritePost .vimrc source $MYVIMRC
" Restore cursor position
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
" Filetypes
autocmd FileType htmldjango set ft=html.htmldjango
autocmd FileType html set ft=html.javascript
" autocmd FileType scss set ft=scss.css
autocmd FileType stylus set ft=stylus.sass
autocmd! FileType sass,scss syn cluster sassCssAttributes add=@cssColors
autocmd FileType html,css,scss,javascript set iskeyword+=-
autocmd FileType php set iskeyword-=-
autocmd BufRead,BufNewFile *.json set ft=javascript
" autocmd BufRead,BufNewFile *.json set equalprg=python\ -mjson.tool
autocmd BufRead,BufNewFile *.js set ft=javascript.javascript-jquery
autocmd BufRead,BufNewFile *.less set ft=less.css
autocmd BufRead,BufNewFile *.scss set ft=scss.css
autocmd BufRead,BufNewFile *.plaintex set ft=plaintex.tex
autocmd BufRead,BufNewFile *.phtml set ft=html
autocmd BufRead,BufNewFile *.html nmap <leader>o :!open %<cr>
" Avoid syntax-highlighting for files larger than 10MB
autocmd BufReadPre * if getfsize(expand("%")) > 10000*1024 | syntax off | endif
autocmd BufReadPost fugitive://* set bufhidden=delete
" Auto close preview window
" TODO: [24-04-2016] make sure that this is still needed
" autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
" autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" NeoComplete, Neosnippet
" TODO: [24-04-2016] make sure that this is still needed
" autocmd InsertLeave * NeoSnippetClearMarkers
augroup END
set t_Co=256
let g:solarized_termcolors=256
let g:solarized_contrast='high'
let g:solarized_termtrans=1
set background=light
colorscheme solarized
" Unite
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#custom#source('file_rec,file_rec/async,grep', 'ignore_pattern', join(['\.git/', 'tmp/', 'bundle/', 'node_modules/', 'bower_components/', 'dist/', 'libs/', 'log/'], '\|'))
call unite#custom#source('file_rec,file_rec/async', 'max_candidates', 10000)
call unite#custom#source('neomru/file', 'matchers', ['matcher_project_files', 'matcher_fuzzy'])
let g:unite_source_buffer_time_format = ''
" let g:unite_enable_start_insert = 1
" let g:unite_split_rule = "botright"
" let g:unite_force_overwrite_statusline = 0
" let g:unite_winheight = 10
" let g:unite_candidate_icon="▷"
nmap <space> [unite]
nnoremap [unite] <nop>
nnoremap <silent> [unite]<space> :<C-u>Unite -toggle -auto-resize -buffer-name=mixed file_rec/async buffer file_mru bookmark<cr><c-u>
nnoremap <silent> [unite]f :<C-u>Unite -toggle -auto-resize -start-insert -buffer-name=files neomru/file file_rec/async<cr>
nnoremap <silent> [unite]b :<C-u>Unite -auto-resize -buffer-name=buffers buffer<cr>
nnoremap <silent> [unite]/ :<C-u>Unite -no-quit -buffer-name=search grep:.<cr>
nnoremap <silent> [unite]* :<C-u>UniteWithCursorWord -no-quit -buffer-name=search grep:.<cr>
nnoremap <silent> [unite]m :<C-u>Unite -auto-resize -buffer-name=mappings mapping<cr>
" nnoremap <silent> [unite]s :<C-u>Unite -quick-match buffer<cr>
if executable('ag')
let g:unite_source_grep_command='ag'
let g:unite_source_grep_default_opts='--nocolor --nogroup --hidden -S'
let g:unite_source_grep_recursive_opt=''
" let g:unite_source_grep_search_word_highlight = 1
elseif executable('ack')
let g:unite_source_grep_command='ack'
let g:unite_source_grep_default_opts='--no-group --no-color'
let g:unite_source_grep_recursive_opt=''
" let g:unite_source_grep_search_word_highlight = 1
endif
" vimfiler
" let g:vimfiler_as_default_explorer = 1
call vimfiler#custom#profile('default', 'context', {
\ 'safe' : 0
\ })
let g:vimfiler_ignore_pattern = []
" Like Textmate icons.
let g:vimfiler_tree_leaf_icon = ' '
let g:vimfiler_tree_opened_icon = '▾'
let g:vimfiler_tree_closed_icon = '▸'
nmap <silent> <Bs> :VimFiler -simple<CR>
nmap <silent> <leader>f :VimFiler -simple -find<CR>
let g:vimshell_interactive_update_time = 500
let g:vimshell_disable_escape_highlight = 1
nnoremap <silent><leader>h :VimShell<CR>
" fugitive
nmap <silent> <leader>b :Gblame<cr>
vmap <silent> <leader>b :Gblame<cr>
nmap <silent> <leader>g :Gstatus<cr>
nmap <silent> <leader>w :Gwrite<cr>
" gitv
nmap <leader>gv :Gitv origin/deployed <c-r>=expand("%")<cr><cr>
" delimitMate
let delimitMate_matchpairs = '(:),[:],{:}'
let delimitMate_expand_space = 1
let delimitMate_expand_cr = 1
" Save file by <leader>s
nmap <leader>s :w<cr>
imap <leader>s <esc>:w<cr>
" OPTIMIZE: try to improve behavior
nnoremap Q <c-w>s:bp<cr><c-w>j:bd<cr>
" nnoremap Q :bd<cr>
" nmap <leader>j :JSHint<cr>
" Open files
" Do not set autochdir (working dir should be root)
nnoremap <leader>e :e <c-r>=expand("%:h")<cr>/
nnoremap <leader>d :diffsplit <c-r>=expand("%:h")<cr>/
cmap <leader>e <c-r>=expand("%:h")<cr>/
cnoremap <c-a> <c-b>
" Neocomplete
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" " Define dictionary.
" let g:neocomplete#sources#dictionary#dictionaries = {
" \ 'default' : '',
" \ 'vimshell' : $HOME.'/.vimshell_hist',
" \ 'scheme' : $HOME.'/.gosh_completions'
" \ }
if has('lua')
" Use neocomplete.
" let g:neocomplete#enable_at_startup = 1
" Use smartcase.
" let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
" let g:neocomplete#sources#syntax#min_keyword_length = 3
" let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
" inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
" function! s:my_cr_function()
" return neocomplete#close_popup() . "\<CR>"
" " For no inserting <CR> key.
" "return pumvisible() ? neocomplete#close_popup() : "\<CR>"
" endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
else
" Use neocomplcache.
" let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
" let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
" let g:neocomplcache_min_syntax_length = 3
" let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
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 <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
" function! s:my_cr_function()
" return neocomplcache#smart_close_popup() . "\<CR>"
" " For no inserting <CR> key.
" "return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
" endfunction
" <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()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplcache#close_popup() : "\<Space>"
" AutoComplPop like behavior.
"let g:neocomplcache_enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
endif
" Neosnippet
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
let g:neosnippet#disable_runtime_snippets = {
\ '_' : 1,
\ }
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory='~/.vim/snippets'
nnoremap <silent> <leader>vi :e ~/.vimrc<cr>
nnoremap <silent> <leader>vs :e ~/.vim/snippets/javascript.snippets
nnoremap <silent> <leader>vp :vsp <c-r>=expand("%:h")<cr>/
" Helpers for snipmate
so ~/.vim/snippets/support_functions.vim
" Slime-vim
"
" TODO: replace with vimshell
"
" Typical settings for tmux:
" socket: "default"
" pane: ":0.1"
if executable('tmux')
let g:slime_target = "tmux"
endif
xmap gx <Plug>SlimeRegionSend
" WARN: netrwPlugin has the same mapping
nmap gx <Plug>SlimeParagraphSend
let g:goog_user_conf = {
\ 'langpair': 'en|ru',
\ 'v_key': 'T'
\ }
if has('gui_running')
source ~/.vim/.gvimrc
endif
function! SQLUpperCase()
%s:\<analyze\>\|\<and\>\|\<as\>\|\<by\>\|\<desc\>\|\<exists\>\|\<explain\>\|\<from\>\|\<group\>\|\<in\>\|\<insert\>\|\<intersect\>\|\<into\>\|\<join\>\|\<limit\>\|\<not\>\|\<on\>\|\<order\>\|\<select\>\|\<set\>\|\<update\>\|\<where\>:\U&:i
endfunction
" Creating macros
" :redir @a>
" :history : -20,
" :redir END
" "ap
" Regexp notes
" /text1\(text2\)\@= 'text1' followed by 'text2'
" /\(text1\)\@<=text2 'text2' preceded with 'text1'
"
" Unique characters
" /^((.)(?!.*\2))*$/
" /^(?!.*(.).*\1)/