-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
910 lines (684 loc) · 24.6 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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
"--------------------------------------------------
" NeoBundle Init
" Use 256 colors in vim
" some plugins not work without it
set t_Co=256
" Turn off filetype plugins before bundles init
filetype off
" Auto installing NeoNeoBundle
let isNpmInstalled = executable("npm")
" default path for node-modules
let s:defaultNodeModules = '~/.vim/node_modules/.bin/'
let iCanHazNeoBundle=1
let neobundle_readme=expand($HOME.'/.vim/bundle/neobundle.vim/README.md')
if !filereadable(neobundle_readme)
if !isNpmInstalled
echo "==============================================="
echo "Your need to install npm to enable all features"
echo "==============================================="
endif
echo "Installing NeoBundle.."
silent !mkdir -p $HOME/.vim/bundle
silent !git clone https://github.com/Shougo/neobundle.vim $HOME/.vim/bundle/neobundle.vim
let iCanHazNeoBundle=0
endif
" Call NeoBundle
if has('vim_starting')
set runtimepath+=$HOME/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand($HOME.'/.vim/bundle/'))
" Determine make or gmake will be used for making additional deps for Bundles
let g:make = 'gmake'
if system('uname -o') =~ '^GNU/'
let g:make = 'make'
endif
"--------------------------------------------------
" Bundles
" Let NeoNeoBundle manage NeoNeoBundle
NeoBundle 'Shougo/neobundle.vim'
" Instlall vimrpoc. is uses by unite and neocomplcache
" for async searches and calls
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'mac' : 'make -f make_mac.mak',
\ 'unix': g:make
\ },
\ }
" Some support functions used by delimitmate, and snipmate
NeoBundle 'vim-scripts/tlib'
"Asterisk
NeoBundle 'ipoddubny/asterisk-vim'
"Ael
NeoBundle 'vim-scripts/ael.vim'
" Improve bookmarks in vim
" Allow word for bookmark marks, and nice quickfix window with bookmark list
" NeoBundle 'AndrewRadev/simple_bookmarks.vim'
" plugin for fuzzy file search, most recent files list
" and much more
NeoBundle 'Shougo/unite.vim'
" Snippets engine with good integration with neocomplcache
NeoBundle 'Shougo/neosnippet'
" Default snippets for neosnippet, i prefer vim-snippets
"NeoBundle 'Shougo/neosnippet-snippets'
" Default snippets
NeoBundle 'honza/vim-snippets'
" Dirr diff
NeoBundle 'vim-scripts/DirDiff.vim'
" Colorscheme solarazied for vim
NeoBundle 'roosta/srcery'
" Allow autoclose paired characters like [,] or (,),
" and add smart cursor positioning inside it,
NeoBundle 'Raimondi/delimitMate'
" Add code static check on write
" need to be properly configured.
" I just enable it, with default config,
" many false positive but still usefull
" NeoBundle 'scrooloose/syntastic'
" Install jshint and csslint for syntastic
" Path to jshint if it not installed, then use local installation
if isNpmInstalled
if !executable(expand(s:defaultNodeModules . 'jshint'))
silent ! echo 'Installing jshint' && npm --prefix ~/.vim/ install jshint
endif
if !executable(expand(s:defaultNodeModules . 'csslint'))
silent ! echo 'Installing csslint' && npm --prefix ~/.vim/ install csslint
endif
endif
if isNpmInstalled
if !executable(expand(s:defaultNodeModules . 'eslint'))
silent ! echo 'Installing eslint' && npm --prefix ~/.vim/ install eslint
endif
endif
" Great file system explorer, it appears when you open dir in vim
" Allow modification of dir, and may other things
" Must have
NeoBundle 'scrooloose/nerdtree'
" Provide smart autocomplete results for javascript, and some usefull commands
if has("python") && isNpmInstalled
" install tern and node dependencies for tern
NeoBundle 'marijnh/tern_for_vim', {
\ 'build' : {
\ 'unix' : 'npm install'
\ }
\ }
endif
" Add smart commands for comments like:
" gcc - Toggle comment for the current line
" gc - Toggle comments for selected region or number of strings
" Very usefull
NeoBundle 'tomtom/tcomment_vim'
" Best git wrapper for vim
" But with my workflow, i really rarely use it
" just Gdiff and Gblame sometimes
NeoBundle 'tpope/vim-fugitive'
" Fix-up dot command behavior
" it's kind of service plugin
NeoBundle 'tpope/vim-repeat'
" Add usefull hotkey for operation with surroundings
" cs{what}{towhat} - inside '' or [] or something like this allow
" change surroundings symbols to another
" and ds{what} - remove them
NeoBundle 'tpope/vim-surround'
" Syntax highlighting for Stylus
NeoBundle 'wavded/vim-stylus'
" Add aditional hotkeys
" Looks like i'm not using it at all
"NeoBundle 'tpope/vim-unimpaired'
" HTML5 + inline SVG omnicomplete funtion, indent and syntax for Vim.
NeoBundle 'othree/html5.vim'
" Syntax highlighting for .jsx (js files for react js)
NeoBundle 'mxw/vim-jsx'
" Highlights the matching HTML tag when the cursor
" is positioned on a tag.
NeoBundle 'gregsexton/MatchTag'
" Add Support css3 property
NeoBundle 'hail2u/vim-css3-syntax'
" Add support for mustache/handlebars
NeoBundle 'mustache/vim-mustache-handlebars'
" Add support for jade
NeoBundle 'digitaltoad/vim-jade'
" Add support for markdown
NeoBundle 'tpope/vim-markdown'
" Automatically add closing tags in html-like formats
NeoBundle 'alvan/vim-closetag'
" Smart indent for javascript
" http://www.vim.org/scripts/script.php?script_id=3081
NeoBundle 'lukaszb/vim-web-indent'
" Plugin for changing cursor when entering in insert mode
" looks like it works fine with iTerm Konsole adn xerm
" Applies only on next vim launch after NeoBundleInstall
NeoBundle 'jszakmeister/vim-togglecursor'
" Nice statusline/ruler for vim
" NeoBundle 'vim-airline/vim-airline'
" NeoBundle 'vim-airline/vim-airline-themes'
NeoBundle 'itchyny/lightline.vim'
" Improve javascritp syntax higlighting, needed for good folding,
" and good-looking javascritp code
NeoBundle 'jelera/vim-javascript-syntax'
"code-completion for jquery, lodash e.t.c
NeoBundle 'othree/javascript-libraries-syntax.vim'
" Improved json syntax highlighting
NeoBundle 'elzr/vim-json'
" Code complete
NeoBundle 'Shougo/neocomplcache.vim'
" Most recent files source for unite
NeoBundle 'Shougo/neomru.vim'
" Plugin for chord mappings
NeoBundle 'kana/vim-arpeggio'
"Jsbeautify
NeoBundle 'maksimr/vim-jsbeautify'
"Auto-pairs brackets
NeoBundle 'jiangmiao/auto-pairs'
" JShint :)
" But not necessary with syntastics
NeoBundle 'walm/jshint.vim'
NeoBundle 'isRuslan/vim-es6'
NeoBundle 'altercation/vim-colors-solarized'
NeoBundle 'flazz/vim-colorschemes'
NeoBundle 'mattn/emmet-vim'
NeoBundle 'bentayloruk/vim-react-es6-snippets'
NeoBundle 'cakebaker/scss-syntax.vim'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'jpalardy/vim-slime'
let g:slime_target = "tmux"
call neobundle#end()
" Enable Indent in plugins
filetype plugin indent on
" Enable syntax highlighting
syntax on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
" disable annoying prompt on initial bundle install
set nomore
" fix issue when github refuse connections on initial install
let g:neobundle#install_max_processes=2
" Install all bundles on first launch
if !iCanHazNeoBundle
NeoBundleInstall
endif
" Check new bundles on startup
NeoBundleCheck
"--------------------------------------------------
" Bundles settings
"-------------------------
" Unite
" Set unite window height
let g:unite_winheight = 10
" Start unite in insert mode by default
let g:unite_enable_start_insert = 1
" Display unite on the bottom (or bottom right) part of the screen
let g:unite_split_rule = 'botright'
" Set short limit for max most recent files count.
" It less unrelative recent files this way
let g:unite_source_file_mru_limit = 100
" Enable history for yanks
let g:unite_source_history_yank_enable = 1
" Make samll limit for yank history,
let g:unite_source_history_yank_limit = 40
" Grep options Default for unite + supress error messages
let g:unite_source_grep_default_opts = '-iRHns'
let g:unite_source_rec_max_cache_files = 99999
" If ack exists use it instead of grep
if executable('ack-grep')
" Use ack-grep
let g:unite_source_grep_command = 'ack-grep'
" Set up ack options
let g:unite_source_grep_default_opts = '--no-heading --no-color -a -H'
let g:unite_source_grep_recursive_opt = ''
endif
" Hotkey for open window with most recent files
nnoremap <silent><leader>m :<C-u>Unite file_mru <CR>
" Hotkey for open history window
nnoremap <silent><leader>h :Unite -quick-match -max-multi-lines=2 -start-insert -auto-quit history/yank<CR>
" Quick tab navigation
nnoremap <silent><leader>' :Unite -quick-match -auto-quit tab<CR>
" Fuzzy find files
nnoremap <silent><leader>; :Unite file_rec/async:! -buffer-name=files -start-insert<CR>
" Unite-grep
nnoremap <silent><leader>/ :Unite grep:. -no-start-insert -no-quit -keep-focus -wrap<CR>
"-------------------------
" NERDTree
" Tell NERDTree to display hidden files on startup
let NERDTreeShowHidden=1
" Disable bookmarks label, and hint about '?'
let NERDTreeMinimalUI=1
" Display current file in the NERDTree ont the left
nmap <silent> <leader>f :NERDTreeFind<CR>
"-------------------------
" Syntastic
function! s:FindSyntasticExecPath(toolName)
if executable(a:toolName)
return a:toolName
endif
let fullPath=fnamemodify('.', ':p:h')
while fullPath != fnamemodify('/', ':p:h')
if filereadable(expand(fullPath . '/node_modules/.bin/' . a:toolName))
return fullPath . '/node_modules/.bin/' . a:toolName
endif
let fullPath = fnamemodify(fullPath . '/../', ':p:h')
endwhile
return s:defaultNodeModules . a:toolName
endfunction
" setting up jshint csslint and jscs if available
let g:syntastic_javascript_jscs_exec = s:FindSyntasticExecPath('jscs')
let g:syntastic_css_csslint_exec= s:FindSyntasticExecPath('csslint')
let g:syntastic_javascript_checkers = ['eslint']
" Enable autochecks
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1
" For correct works of next/previous error navigation
let g:syntastic_always_populate_loc_list = 1
" check json files with jshint
let g:syntastic_filetype_map = { "json": "javascript", }
let g:syntastic_javascript_checkers = ["jshint", "jscs"]
" open quicfix window with all error found
nmap <silent> <leader>ll :Errors<cr>
" previous syntastic error
nmap <silent> [ :lprev<cr>
" next syntastic error
nmap <silent> ] :lnext<cr>
"-------------------------
" Fugitive
" Blame on current line
nmap <silent> <leader>b :.Gblame<cr>
" Blame on all selected lines in visual mode
vmap <silent> <leader>b :Gblame<cr>
" Git status
nmap <silent> <leader>gst :Gstatus<cr>
" like git add
nmap <silent> <leader>gw :Gwrite<cr>
" git diff
nmap <silent> <leader>gd :Gdiff<cr>
" git commit
nmap <silent> <leader>gc :Gcommit<cr>
" git commit all
nmap <silent> <leader>gca :Gcommit -a<cr>
" git fixup previous commit
nmap <silent> <leader>gcf :Gcommit -a --amend<cr>
"-------------------------
" DelimitMate
" Delimitmate place cursor correctly n multiline objects e.g.
" if you press enter in {} cursor still be
" in the middle line instead of the last
let delimitMate_expand_cr = 1
" Delimitmate place cursor correctly in singleline pairs e.g.
" if x - cursor if you press space in {x} result will be { x } instead of { x}
let delimitMate_expand_space = 1
" Without this we can't disable delimitMate for specific file types
let loaded_delimitMate = 1
"-------------------------
" vim-mustache-handlebars
" Enable shortcuts for things like {{{ an {{
let g:mustache_abbreviations = 1
"-------------------------
" vim-closetag
" Enable for files with this extensions
let g:closetag_filenames = "*.handlebars,*.html,*.xhtml,*.phtml"
"-------------------------
" Tern_for_vim
let tern_show_signature_in_pum = 1
" Find all refs for variable under cursor
nmap <silent> <leader>tr :TernRefs<CR>
" Smart variable rename
nmap <silent> <leader>tn :TernRename<CR>
"-------------------------
" neosnippets
"
" Enable snipMate compatibility
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" Disables standart snippets. We use vim-snippets bundle instead
let g:neosnippet#disable_runtime_snippets = { '_' : 1 }
" Expand snippet and jimp to next snippet field on Enter key.
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>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"-------------------------
" vim-airline
" Colorscheme for airline
" let g:airline_theme='luna'
" Set custom left separator
" let g:airline_left_sep = '▶'
" Set custom right separator
" let g:airline_right_sep = '◀'
" Enable airline for tab-bar
" let g:airline#extensions#tabline#enabled = 1
" Don't display buffers in tab-bar with single tab
" let g:airline#extensions#tabline#show_buffers = 0
" Display only filename in tab
" let g:airline#extensions#tabline#fnamemod = ':t'
" Don't display encoding
" let g:airline_section_y = ''
" Don't display filetype
" let g:airline_section_x = ''
let g:lightline = {
\ 'component_function': {
\ 'filename': 'LightlineFilename',
\ 'gitbranch': 'fugitive#head'
\ },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'colorscheme': 'solarized'
\ }
function! LightlineFilename()
return &filetype ==# 'vimfiler' ? vimfiler#get_status_string() :
\ &filetype ==# 'unite' ? unite#get_status_string() :
\ &filetype ==# 'vimshell' ? vimshell#get_status_string() :
\ expand('%:t') !=# '' ? expand('%:t') : '[No Name]'
endfunction
let g:unite_force_overwrite_statusline = 0
let g:vimfiler_force_overwrite_statusline = 0
let g:vimshell_force_overwrite_statusline = 0
"-------------------------
" neocomplcache
" Enable NeocomplCache at startup
let g:neocomplcache_enable_at_startup = 1
" Max items in code-complete
let g:neocomplcache_max_list = 10
" Max width of code-complete window
let g:neocomplcache_max_keyword_width = 80
" Code complete is ignoring case until no Uppercase letter is in input
let g:neocomplcache_enable_smart_case = 1
" Auto select first item in code-complete
let g:neocomplcache_enable_auto_select = 1
" Disable auto popup
let g:neocomplcache_disable_auto_complete = 1
" Smart tab Behavior
function! CleverTab()
" If autocomplete window visible then select next item in there
if pumvisible()
return "\<C-n>"
endif
" If it's begining of the string then return just tab pressed
let substr = strpart(getline('.'), 0, col('.') - 1)
let substr = matchstr(substr, '[^ \t]*$')
if strlen(substr) == 0
" nothing to match on empty string
return "\<Tab>"
else
" If not begining of the string, and autocomplete popup is not visible
" Open this popup
return "\<C-x>\<C-u>"
endif
endfunction
inoremap <expr><TAB> CleverTab()
" Undo autocomplete
inoremap <expr><C-e> neocomplcache#undo_completion()
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" For cursor moving in insert mode
inoremap <expr><Left> neocomplcache#close_popup() . "\<Left>"
inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>"
inoremap <expr><Up> neocomplcache#close_popup() . "\<Up>"
inoremap <expr><Down> neocomplcache#close_popup() . "\<Down>"
" disable preview in code complete
set completeopt-=preview
"-------------------------
" Arpeggio
" map jk to escape
call arpeggio#map('i', '', 0, 'jk', '<ESC>')
"--------------------------------------------------
" Цветовая схема
" использовать srcery
syntax enable
" set background=dark
" colorscheme gruvbox
" colorscheme railscasts
" colorscheme colorsbox-material
" colorscheme 1989
" colorscheme deepsea
" set highlighting for colorcolumn
highlight ColorColumn ctermbg=lightGrey
"--------------------------------------------------
" General options
" Enable per-directory .vimrc files and disable unsafe commands in them
"set exrc secure
" Set up leader key <leader>, i use default \
"let mapleader = ','
" Buffer will be hidden instead of closed when no one display it
"set hidden
" Auto reload changed files
set autoread
" Always change current dirrectory to current-editing-file dir
"set autochdir
" Indicates fast terminal connection
set ttyfast
" Set character encoding to use in vim
set encoding=utf-8
" Let vim know what encoding we use in our terminal
set termencoding=utf-8
" Which EOl used. For us it's unix
" Not works with modifiable=no
if &modifiable
set fileformat=unix
endif
" Enable Tcl interface. Not shure what is exactly mean.
" set infercase
" Interprete all files like binary and disable many features.
" set binary
"--------------------------------------------------
" Display options
" Hide showmode
" Showmode is useless with airline
set noshowmode
" Show file name in window title
set title
" Mute error bell
set novisualbell
" Remove all useless messages like intro screen and use abbreviation like RO
" instead readonly and + instead modified
set shortmess=atI
" Enable display whitespace characters
set list
" Setting up how to display whitespace characters
set listchars=tab:⇥\ ,trail:·,extends:⋯,precedes:⋯,nbsp:~
" Wrap line only on characters in breakat list like ^I!@*-+;:,./?
" Useless with nowrap
" set linebreak
" Numbers of line to scroll when the cursor get off the screen
" Useless with scrolloff
" set scrolljump=5
" Numbers of columns to scroll when the cursor get off the screen
" Useless with sidescrollof
" set sidescroll=4
" Numbers of rows to keep to the left and to the right off the screen
set scrolloff=10
" Numbers of columns to keep to the left and to the right off the screen
set sidescrolloff=10
" Vim will move to the previous/next line after reaching first/last char in
" the line with this commnad (you can add 'h' or 'l' here as well)
" <,> stand for arrows in command mode and [,] arrows in visual mode
set whichwrap=b,s,<,>,[,],
" Display command which you typing and other command related stuff
set showcmd
" Indicate that last window have a statusline too
set laststatus=2
" Add a line / column display in the bottom right-hand section of the screen.
" Not needed with airline plugin
"set ruler
" Setting up right-hand section(ruller) format
" Not needed with airline plugin
"set rulerformat=%30(%=\:%y%m%r%w\ %l,%c%V\ %P%)
" The cursor should stay where you leave it, instead of moving to the first non
" blank of the line
set nostartofline
" Disable wrapping long string
set nowrap
" Display Line numbers
set number
" Highlight line with cursor
set cursorline
" maximum text length at 80 symbols, vim automatically breaks longer lines
" set textwidth=80
" higlight column right after max textwidth
set colorcolumn=+1
"--------------------------------------------------
" Tab options
" Copy indent from previous line
set autoindent
" Enable smart indent. it add additional indents whe necessary
set smartindent
" Replace tabs with spaces
set expandtab
" Whe you hit tab at start of line, indent added according to shiftwidth value
set smarttab
" number of spaces to use for each step of indent
set shiftwidth=4
" Number of spaces that a Tab in the file counts for
set tabstop=4
" Same but for editing operation (not shure what exactly does it means)
" but in most cases tabstop and softtabstop better be the same
set softtabstop=4
" Round indent to multiple of 'shiftwidth'.
" Indentation always be multiple of shiftwidth
" Applies to < and > command
set shiftround
"--------------------------------------------------
" Search options
" Add the g flag to search/replace by default
set gdefault
" Highlight search results
set hlsearch
" Ignore case in search patterns
set ignorecase
" Override the 'ignorecase' option if the search patter ncontains upper case characters
set smartcase
" Live search. While typing a search command, show where the pattern
set incsearch
" Disable higlighting search result on Enter key
nnoremap <silent> <cr> :nohlsearch<cr><cr>
" Show matching brackets
set showmatch
" Make < and > match as well
set matchpairs+=<:>
"--------------------------------------------------
" Wildmenu
" Extended autocmpletion for commands
set wildmenu
" Autocmpletion hotkey
set wildcharm=<TAB>
"--------------------------------------------------
" Folding
" Enable syntax folding in javascript
let javaScript_fold=1
" No fold closed at open file
set foldlevelstart=99
set nofoldenable
" Keymap to toggle folds with space
nmap <space> za
"--------------------------------------------------
" Edit
" Allow backspace to remove indents, newlines and old text
set backspace=indent,eol,start
" toggle paste mode on \p
set pastetoggle=<leader>p
" Add '-' as recognized word symbol. e.g dw delete all 'foo-bar' instead just 'foo'
set iskeyword+=-
" Disable backups file
set nobackup
" Disable vim common sequense for saving.
" By defalut vim write buffer to a new file, then delete original file
" then rename the new file.
set nowritebackup
" Disable swp files
set noswapfile
" Do not add eol at the end of file.
set noeol
"--------------------------------------------------
" Diff Options
" Display filler
set diffopt=filler
" Open diff in horizontal buffer
set diffopt+=horizontal
" Ignore changes in whitespaces characters
set diffopt+=iwhite
"--------------------------------------------------
" Hotkeys
" Open new tab
nmap <silent><leader>to :tabnew .<CR>
" Replace
nmap <leader>s :%s//<left>
vmap <leader>s :s//<left>
" Moving between splits
nmap <leader>w <C-w>w
"--------------------------------------------------
"JsBeautify
map <c-f> :call JsBeautify()<cr>
autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
" for json
autocmd FileType json noremap <buffer> <c-f> :call JsonBeautify()<cr>
" " for jsx
autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr>
" " for html
autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr>
" " for css or scss
autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
autocmd FileType javascript let b:syntastic_checkers = findfile('.eslintrc', '.;') !=# '' ? ['eslint'] : []
"--------------------------------------------------
" Aautocmd
" It executes specific command when specific events occured
" like reading or writing file, or open or close buffer
if has("autocmd")
" Define group of commands,
" Commands defined in .vimrc don't bind twice if .vimrc will reload
augroup vimrc
" Delete any previosly defined autocommands
au!
" Auto reload vim after your cahange it
au BufWritePost *.vim source $MYVIMRC | AirlineRefresh
au BufWritePost .vimrc source $MYVIMRC | AirlineRefresh
" Restore cursor position :help last-position-jump
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
" Set filetypes aliases
au FileType htmldjango set ft=html.htmldjango
au FileType scss set ft=scss.css
au FileType less set ft=less.css
au BufWinEnter * if line2byte(line("$") + 1) > 100000 | syntax clear | endif
au BufRead,BufNewFile *.js set ft=javascript.javascript-jquery
au BufRead,BufNewFile *.json set ft=json
" Execute python \ -mjson.tool for autoformatting *.json
au BufRead,BufNewFile *.bemhtml set ft=javascript
au BufRead,BufNewFile *.bemtree set ft=javascript
au BufRead,BufNewFile *.xjst set ft=javascript
au BufRead,BufNewFile *.tt2 set ft=tt2
au BufRead,BufNewFile *.plaintex set ft=plaintex.tex
" Auto close preview window, it uses with tags,
" I don't use it
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" Disable vertical line at max string length in NERDTree
autocmd FileType * setlocal colorcolumn=+1
autocmd FileType nerdtree setlocal colorcolumn=""
" Not enable Folding - it really slow on large files, uses plugin vim-javascript-syntax
" au FileType javascript* call JavaScriptFold()
au FileType html let b:loaded_delimitMate = 1
au FileType handlebars let b:loaded_delimitMate = 1
" Group end
augroup END
endif
syntax enable
set background=dark
colorscheme solarized
call togglebg#map("<F5>")
" set term=xterm-256color
set nocompatible
filetype off
let &runtimepath.=',~/.vim/bundle/ale'
filetype plugin on