-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc_src
779 lines (677 loc) · 27.7 KB
/
vimrc_src
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
"##################################################################
" Script Name : Vimrc
"
" Description : vimrc config file
"
" Creation Date : 16-01-2021
" Last Modified : 14-03-2021 [4:30am]
"
" Created By : Nabendu Maiti
" Email : 1206581+nmaiti@users.noreply.github.com
"##################################################################
"------------------------------------------------------------------------------
" Leader Key
"------------------------------------------------------------------------------
let mapleader="," " leader is comma
set encoding=utf8
"set guifont=DejaVu\ Sans\ Mono\ 10
"""""set guifont=Hack\ 10
"set guifont=DroidSansMono\ Nerd\ Font\ 11
set pastetoggle=<F10>
if has("mac") || has("macunix")
set guifont=Monaco:h12
set backspace=indent,eol,start
endif
"FileType support
set filetype=on
filetype plugin indent on
autocmd FileType javascript,html,css,php,yaml set ai
autocmd FileType javascript,html,css,php,yaml set sw=2
autocmd FileType javascript,html,css,php,yaml set ts=2
autocmd FileType javascript,html,css,php,yaml set sts=2
autocmd FileType javascript,css,php set textwidth=0
autocmd FileType html,htm,xml,tpl,yaml set textwidth=0
autocmd FileType yaml setlocal expandtab
colorscheme default
" Install vim-plug if not installed
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
"------------------------------------------------------------------------------
"" syntax, highlighting and spelling
"------------------------------------------------------------------------------
Plug 'josuegaleas/jay'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'Lokaltog/vim-powerline'
Plug 'justinmk/vim-syntax-extra'
Plug 'bronson/vim-trailing-whitespace'
Plug 'Yggdroot/indentLine'
Plug 'vim-scripts/a.vim'
Plug 'pedrohdz/vim-yaml-folds', { 'for': 'yaml' }
Plug 'hari-rangarajan/CCTree'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'nmaiti/fzf_cscope.vim'
if !executable('fzf')
Plug 'mileszs/ack.vim'
endif
"Alignment
"type ;Tabularize /= to align the =
Plug 'godlygeek/tabular', { 'on' : 'Tabularize' }
" File navigation
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'Chiel92/vim-autoformat', { 'on': 'Autoformat' }
Plug 'bling/vim-bufferline'
" Taglist
Plug 'majutsushi/tagbar'
", { 'on': 'TagbarOpenAutoClose' }
" Git
""NBMPlug 'rhysd/conflict-marker.vim'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
"""""if has('nvim') || has('patch-8.0.902')
""""" Plug 'mhinz/vim-signify'
"""""else
""""" Plug 'mhinz/vim-signify', { 'branch': 'legacy' }
"""""endif
" Error checking
Plug 'w0rp/ale'
" Auto Complete
"""" Plug 'ycm-core/YouCompleteMe'
" Undo Tree
Plug 'mbbill/undotree', { 'on': ['UndotreeToggle', 'UndotreeShow'] }
" Other visual enhancement
""Plug 'nathanaelkane/vim-indent-guides'
""Plug 'itchyny/vim-cursorword'
Plug 'gisphm/vim-gitignore', { 'for': ['gitignore', 'vim-plug'] }
" HTML, CSS, JavaScript, PHP, JSON, etc.
Plug 'elzr/vim-json', { 'for': ['yaml', 'json'] }
Plug 'hail2u/vim-css3-syntax', { 'for': ['vim-plug', 'php', 'html','javascript', 'css', 'less'] }
Plug 'spf13/PIV', { 'for' :['php', 'vim-plug'] }
Plug 'gko/vim-coloresque', { 'for': ['vim-plug', 'php', 'html','javascript', 'css', 'less'] }
Plug 'pangloss/vim-javascript', { 'for' :['javascript', 'vim-plug'] }
Plug 'mattn/emmet-vim'
" Python
""""Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
""Plug 'vim-scripts/indentpython.vim'
" Golang
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Markdown
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install_sync()}, 'for' :['markdown', 'vim-plug'] }
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle' }
Plug 'vimwiki/vimwiki', { 'on' : 'Vimwiki' }
" Bookmarks
"Plug 'kshenoy/vim-signature'
" Other useful utilities
Plug 'terryma/vim-multiple-cursors'
" distraction free writing mode
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!'
Plug 'tpope/vim-surround' " type ysks' to wrap the word with '' or type cs'`
"to change 'word' to `word`
Plug 'gcmt/wildfire.vim' " in Visual mode, type i' to select all text in '',
"or type i) i] i} ip
" Dependencies
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'kana/vim-textobj-user'
Plug 'fadein/vim-FIGlet'
" Misc
Plug 'thaerkh/vim-workspace'
Plug 'voldikss/vim-floaterm', { 'on' : ['FloatermToggle', 'FloatermNew'] }
call plug#end()
"------------------------------------------------------------------------------
" Look and feel
"------------------------------------------------------------------------------
set t_Co=1024
if has('gui_running')
" close The toolbar when use gVim
" close the scrollbar when use gVim
set lines=63
set columns=180
set guioptions-=T
set guioptions-=l
set guioptions-=r
set guioptions-=b
" Let tablebel show only name of file, not the full path.
set guitablabel=%t
" paste from system clipboard
set clipboard=unnamed
vnoremap y "+y
"vnoremap y ygv"+y
vnoremap Y "+Y
nnoremap p "+p
nnoremap P "+P
nnoremap yy yy"+yy
endif
if &term =~ "xterm"
" 256 colors
let &t_Co = 256
" restore screen after quitting
let &t_ti = "\<Esc>7\<Esc>[r\<Esc>[?47h"
let &t_te = "\<Esc>[?47l\<Esc>8"
if has("terminfo")
let &t_Sf = "\<Esc>[3%p1%dm"
let &t_Sb = "\<Esc>[4%p1%dm"
else
let &t_Sf = "\<Esc>[3%dm"
let &t_Sb = "\<Esc>[4%dm"
endif
endif
filetype plugin indent off
set ttymouse=xterm2
set mouse=a
"------------------------------------------------------------------------------
" vim autosave workspace
let g:workspace_autosave_always = 1
nnoremap <leader>ss :ToggleWorkspace<CR>
let g:workspace_session_name = '.session.vim'
let g:workspace_autosave_ignore = ['gitcommit', 'qf', 'nerdtree', 'tagbar']"
let g:workspace_autosave = 1
set sessionoptions-=blank
"------------------------------------------------------------------------------
"--- Force termial 256 color
"------------------------------------------------------------------------------
set t_Co=256
set term=xterm-256color
"colorscheme github "solarized delek
if has('gui_running')
set background=light
else
set background=dark
endif
try
colorscheme jay
catch /^Vim\%((\a\+)\)\=:E185/
" deal with it
colorscheme default
endtry
"set background=dark
"colorscheme jay
"""""colorscheme jay "srcery
"colorscheme solarized "Dark delek
"let g:solarized_termcolors = 256
"let g:solarized_termtrans = 1
"let g:solarized_visibility = "high"
"let g:solarized_contrast = "high"
" Automatic reloading of .vimrc
"autocmd! bufwritepost .vimrc source %
"------------------------------------------------------------------------------
" syntax, highlighting and spelling
"------------------------------------------------------------------------------
"--------------- Powerline settings ------------------------------------------
let g:Powerline_symbols = 'fancy'
set encoding=utf-8
set t_Co=256
set term=xterm-256color
set termencoding=utf-8
"----- C syntax highlightng (cppextra syntax highligting) - --------------------
let g:cpp_attributes_highlight = 1
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_experimental_template_highlight = 1
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 0
"--------- Open Last Edit Position -----------------------------------------
if has("autocmd")
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
endif
"------------------------------------------------------------------------------
" tabs and indenting
" Real programmers don't use TABs but spaces
"------------------------------------------------------------------------------
set tabstop=4 " tab = 8 spaces
set shiftwidth=4 " autoindent indents 2 spaces
set smarttab " <TAB> in front of line inserts 'shiftwidth' blanks
set softtabstop=4
"set noexpandtab
set expandtab
set shiftround " Indent to nearest tabstop
set autoindent " Carries over previous indent to the next line
set cindent " Carries over previous indent to the next line
set cursorline
"------------------------------------------------------------------------------
" displaying text
"------------------------------------------------------------------------------
syntax on " Enable syntax
set scrolloff=3 " number of screen lines to show around the cursor
set linebreak " For lines longer than the window, wrap intelligently.
" This doesn't insert hard line breaks.
set showbreak=?\ \ " string to put before wrapped screen lines
set sidescrolloff=2 " min # of columns to keep left/right of cursor
set display+=lastline " show last line, even if it doesn't fit in the window
set cmdheight=3 " # of lines for the command window
" cmdheight=2 helps avoid 'Press ENTER...' prompts
set number " show line numbers
"------------- color column at 80th letter ------------------------------------
if exists('+colorcolumn')
set colorcolumn=80 " display a line in column 80 to show you
" where to line break.
highlight ColorColumn ctermbg=darkred ctermfg=lightblue
highlight Search ctermbg=darkgrey ctermfg=lightgreen
endif
"NBMhighlight Search ctermbg=darkgrey ctermfg=lightgreen
"------------------------------------------------------------------------------
" messages and info
"------------------------------------------------------------------------------
set showcmd " In the status bar, show incomplete commands as they are typed
set ruler " Always display the current cursor position in the Status Bar
set confirm " Ask to save buffer instead of failing when executing
" commands which close buffers
"------------------------------------------------------------------------------
" editing text
"------------------------------------------------------------------------------
set backspace=indent,eol,start "backspace over everything
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j "delete comment char on second line when
" joining two commented lines
endif
set showmatch " when inserting a bracket, briefly jump to its
" match
set nojoinspaces " Use only one space after '.' when joining
" lines, instead of two
set nrformats-=octal " don't treat numbers with leading zeros as octal
" when incrementing / decrementing
"------------------------------------------------------------------------------
" diff mode
" -----------------------------------------------------------------------------
set diffopt+=vertical " start diff mode with vertical splits by default
"------------------------------------------------------------------------------
" reading and writing files
"------------------------------------------------------------------------------
set autoread " Automatically re-read files changed outside
" of Vim
"------------------------------------------------------------------------------
" command line editing
set history=700
set undolevels=700
"------------------------------------------------------------------------------
" Command mode auto completion
set wildmode=list:longest,full
" File tab completion ignores these file patterns
set wildignore+=*.exe,*.swp,.DS_Store
set wildmenu
" Add guard around 'wildignorecase' to prevent terminal vim error
if exists('&wildignorecase')
set wildignorecase
endif
" Copy to system clipboard
func! GetSelectedText()
normal gv"xy
let result = getreg("x")
return result
endfunc
" copy line ,cv ; cut line ,ct ; relative path ,cr ; absolute path ,ca
if !has("clipboard") && executable("clip.exe") " For wsl
map ,cp :call system('clip.exe', GetSelectedText())<CR>
map ,ct :call system('clip.exe', GetSelectedText())<CR>gvx
map ,cr :call system('clip.exe', expand("%"))<CR>
map ,ca :call system('clip.exe', expand("%:p"))<CR>
else
map ,cp :let @* =GetSelectedText()<CR>
map ,ct :let @* =GetSelectedText()<CR>
map ,cr :let @* =expand("%")<CR>
map ,ca :let @* =expand("%:p")<CR>
endif
"------------------------------------------------------------------------------
" Window Management
"------------------------------------------------------------------------------
" Use left, right, up, down arrow to modify windows size.
"nmap <leader><LEFT> :<C-W>< <CR>
"nmap <leader><RIGHT> <C-W>>
"nmap <leader><UP> <C-W>+
"nmap <leader><DOWN> <C-W>-
noremap <silent> <C-S-LEFT> :vertical resize +1<CR>
noremap <silent> <C-S-RIGHT> :vertical resize -1<CR>
noremap <silent> <C-S-UP> :res +1 <CR>
noremap <silent> <C-S-DOWN> :res -1<CR>
" bind Ctrl+<movement> keys to move around the windows,
" instead of using Ctrl+w + <movement>
map <tab><tab> <C-w>w
map <tab><LEFT> <C-w>h
map <tab><RIGHT> <C-w>l
map <tab><UP> <C-w>k
map <tab><DOWN> <C-w>j
map <tab><DOWN> <C-w>j
" for bottom-right and top-left movement
map <tab>> <C-w>b
map <tab>< <C-w>t
"map <c-j> <c-w>j
"map <c-k> <c-w>k
"map <c-l> <c-w>l
"map <c-h> <c-w>h
"
" easier moving between tabs
set hidden
" switch between buffer move /also can be used by CtrlP
nmap <leader>bn :bnext<CR>
nmap <leader>bp :bprev<CR>
vmap <leader>bn :bnext<CR>
vmap <leader>bp :bprev<CR>
"imap <C-t> <Esc>:tabnew<CR>
"map <leader>n <esc>:tabprevious<CR>
"map <leader>m <esc>:tabnext<CR>
"map <leader>w <esc>:tabclose<CR>
"------------------------------------------------------------------------------
" tab control mapping
"------------------------------------------------------------------------------
map <C-Left> <Esc>:tabprev<CR>
map <C-Right> <Esc>:tabnext<CR>
map <leader>tn <Esc>:tabnew<CR>
"map <C-n> <Esc>:tabnew<CR>
"same as window close
map <leader><leader>x <Esc>:tabclose<CR>
" easier moving of code blocks
" Try to go into visual mode (v), thenselect several lines of code here and
" then press ``>`` several times.
vnoremap < <gv " better indentation
vnoremap > >gv " better indentation
"----------------- Save Or Quit -----------------------------------------------
" Quicksave command
noremap <Leader>s :update<CR>
vnoremap <Leader>s <C-C>:update<CR>
inoremap <Leader>s <C-O>:update<CR>
" Quick quit command
noremap <Leader>x :quit<CR> " Quit current window
noremap <Leader>X :qa!<CR> " Quit all windows
" Remove unwanted spaces
map <leader>rs :%s/\s\+$//<CR>
" Removes highlight of your last search
" ``<C>`` stands for ``CTRL`` and therefore ``<C-h>`` stands for ``CTRL+h``
noremap <C-h> :nohl<CR>
vnoremap <C-h> :nohl<CR>
inoremap <C-h> :nohl<CR>
map <leader>n <esc>:cn<CR>
map <leader>p <esc>:cp<CR>
" map sort function to a key
"" vnoremap <Leader>s :sort<CR>
" Make search case insensitive
set nostartofline " keep cursor in same column for long-range motion cmds
set incsearch " Highlight pattern matches as you type
set ignorecase " ignore case when using a search pattern
set smartcase " override 'ignorecase' when have upper case character
set hlsearch " set search high light
" Disable stupid backup and swap files - they trigger too many events
" for file system watchers
set nobackup
set nowritebackup
set noswapfile
" some shortcut for myself
" using `less` to open current file, since less is easier to copy from.
nmap <leader>ls <esc>:!less %<CR>
set laststatus=2
"------------------------------------------------------------------------------
" vim-clang-format.vim
"------------------------------------------------------------------------------
let g:clang_format#style_options = {
\ "AccessModifierOffset" : -4,
\ "AllowShortIfStatementsOnASingleLine" : "true",
\ "AlwaysBreakTemplateDeclarations" : "true",
\ "Standard" : "C++11",
\ "BreakBeforeBraces" : "Stroustrup"}
" map to <Leader>cf in C++ code
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
" Use .clang-format file if available
let g:clang_format#detect_style_file = 1
"-- uncomment below for c autoformat
"autocmd FileType c ClangFormatAutoEnable
"=============================================================================
" Window movement
"------------------------------------------------------------------------------
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" fzf
" This is the default option:
" - Preview window on the right with 50% width
" - CTRL-/ will toggle preview window.
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
" - To learn more about preview window options, see `--preview-window`
" section of `man fzf`.
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
" Preview window on the upper side of the window with 40% height,
" hidden by default, ctrl-/ to toggle
"let g:fzf_preview_window = ['up:40%:hidden', 'ctrl-/']
map <c-p> :Files<CR>
map <c-b> :Buffers<CR>
if executable('ag')
"use silversearcher if available
let g:ackprg = 'ag --vimgrep'
endif
if executable('rg')
let g:ackprg = 'rg --vimgrep --no-heading'
endif
if !executable('fzf') "fzf not installed use ack.vim
cnoreabbrev Ack Ack!
" Ack word under the cursor
noremap <Leader>aw :Ack! <C-R>=expand("<cword>")<CR><CR>
noremap <Leader>af :AckFile <space>
nnoremap <Leader>ac :Ack!<Space>
else
nnoremap <Leader>ac :Files<CR>
if executable('rg')
map <c-a> :Rg<CR>
noremap <Leader>aw :Rg <C-R>=expand("<cword>")<CR><CR>
"Find c expression under cursor
noremap <Leader>af :Rg <C-R>=expand("<cexpr>")<CR><CR>
else " use ag
if executable('ag')
" Ack word under the cursor
noremap <Leader>aw :Ag <C-R>=expand("<cword>")<CR><CR>
noremap <Leader>af :Ag <space>
endif
endif
endif
"------------------------------------------------------------------------------
" Git Gutter
"------------------------------------------------------------------------------
let g:gitgutter_max_signs=-1 " git gutter max size
let g:gitgutter_preview_win_floating = 1
map <leader>g <esc>:GitGutterPreviewHunk<cr>
"------------------------------------------------------------------------------
" Tagbar plugin
" -----------------------------------------------------------------------------
let g:tagbar_sort = 0
autocmd FileType python,c,cpp TagbarOpen " Tagbar auto open
map <leader>tb :TagbarToggle<cr>
vmap <leader>tb <esc>:TagbarToggle<cr>
imap <leader>tb <esc>:TagbarToggle<cr>
"------------------------------------------------------------------------------
" NerdTree plugin
"------------------------------------------------------------------------------
let Tlist_Use_Right_Window = 1
let NERDTreeQuitOnOpen = 0
let NERDTreeIgnore=['.pyc$[[file]]','.gitignore$[[dir]]']
let g:nerdtree_tabs_open_on_gui_startup = 1
let NERDTreeShowHidden = 1 "Show hidden files
map <F5> :NERDTreeToggle<cr>
vmap <F5> <esc>:NERDTreeToggle<cr>
imap <F5> <esc>:NERDTreeToggle<cr>
map <leader>nt :NERDTreeToggle<cr>
vmap <leader>nt <esc>:NERDTreeToggle<cr>
imap <leader>nt <esc>:NERDTreeToggle<cr>
autocmd vimenter * if !argc() | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Start NERDTree when Vim starts with a directory argument.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
" Open the existing NERDTree on each new tab.
" autocmd BufWinEnter * silent NERDTreeMirror
"
"let g:NERDTreeGitStatusUseNerdFonts = 1
" Uncomment following to use auto refresh/else use 'R' command while focus on
" NERDTree window
" autocmd BufWritePost * NERDTreeFocus | execute 'normal R' | wincmd p
"------------------------------------------------------------------------------
" CCTree
"------------------------------------------------------------------------------
let g:CCTreeKeyHilightTree = ''
let g:CCTreeKeyToggleWindow = '<C-c>w'
let g:CCTreeKeyTraceForwardTree = '<C-c>>'
let g:CCTreeKeyTraceReverseTree = '<C-c><'
let g:CCTreeKeyDepthPlus = '<C-c>]'
let g:CCTreeKeyDepthMinus = '<C-c>['
let g:CCTreeMinVisibleDepth = 2
let g:CCTreeDisplayMode = 2
"map <leader>cc <esc>:CCTreeLoadDB cscope.out<cr>
map <leader>cc <esc>:call RefreshCCTree() <CR>
" -----------------------------------------------------------------------------
" Cscope cctree ctags update
" -----------------------------------------------------------------------------
map <F6> :!cscope -bR<CR>:cs reset<CR>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . <CR> <CR>
"map <F7> :call RefreshCCTree() <CR>
"------------------------------------------------------------------------------
" Easy Motion
"------------------------------------------------------------------------------
map <leader>a <leader><leader>w
"------------------------------------------------------------------------------
" python--mode
"`https://github.com/klen/python-mode
"------------------------------------------------------------------------------
au FileType python map <Leader>g :call pymode#rope#goto_definition()<CR>
let g:pymode = 1
let g:pymode_run = 0
let g:pymode_folding=0
let g:pymode_lint_checker="pyflakes,pep8"
let g:pymode_lint_ignore="N4,E12,E711,E712,E721,E502,E501"
let g:pymode_rope_enable_shortcuts=0
let pymode_rope_vim_completion=0
let pymode_rope_extended_complete=0
let g:pymode_rope_regenerate_on_write = 0
"let g:pymode_rope_enable_autoimport=0
let g:pymode_rope_goto_def_newwin="new"
let g:pymode_rope_guess_project = 1
let g:pymode_rope = 1
let g:pymode_rope_completion = 0
"------------------------------------------------------------------------------
" vim-go
"------------------------------------------------------------------------------
au FileType go nmap <Leader>g <Plug>(go-def)
au FileType go nmap <Leader>gs <Plug>(go-def-split)
au FileType go nmap <Leader>gv <Plug>(go-def-vertical)
au FileType go nmap <Leader>gt <Plug>(go-def-tab)
let g:go_version_warning = 0
let g:go_fmt_autosave = 0
"------------------------------------------------------------------------------
" vim-markdown
"------------------------------------------------------------------------------
let g:vim_markdown_folding_disabled = 1
"------------------------------------------------------------------------------
" indentline
"------------------------------------------------------------------------------
let g:indentLine_fileTypeExclude = ['html', 'htm']
let g:indentLine_color_term = 239
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
"let g:indentLine_bgcolor_term = 12
let g:indentLine_bgcolor_gui = '#FF5F00'
let g:indentLine_color_tty_light = 4 " (default: 4)
let g:indentLine_color_dark = 2 " (default: 2)
"------------------------------------------------------------------------------
" Folding
"------------------------------------------------------------------------------
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
" space open/closes folds
nnoremap <space> za
set foldmethod=indent " fold based on indent level
" -----------------------------------------------------------------------------
" Session Save mapping
" -----------------------------------------------------------------------------
" save session
nnoremap <leader>s :mksession<CR>
" default is ~/.vim/sessions.
"let g:vsession_path = '/to/your/path'
" if installed fzf.vim, you can use fzf's interface to load and delete session.
" default is false.
let g:vsession_use_fzf = 1
"------------------------------------------------------------------------------
" setlocal spell spelllang=en_us
" Set spell checking on vim git commit
"------------------------------------------------------------------------------
autocmd BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
"------------------------------------------------------------------------------
" vim-autoformat
map <leader>fa :Autoformat<CR>
"------------------------------------------------------------------------------
" linux coding style formating
let g:linuxsty_patterns = [ "/usr/src/", "/linux" ]
nnoremap <silent> <leader>lx :LinuxCodingStyle<cr>
"------------------------------------------------------------------------------
" Ominicppcomplete
"------------------------------------------------------------------------------
filetype plugin indent on
set omnifunc=syntaxcomplete#Complete
"set completeopt+=longest " better omni-complete menu
let OmniCpp_DisplayMode = 1
let OmniCpp_ShowScopeInAbbr = 1 "do not show namespace in pop-up
let OmniCpp_ShowPrototypeInAbbr = 1 "show prototype in pop-up
let OmniCpp_ShowAccess = 1 "show access in pop-up
let OmniCpp_SelectFirstItem = 2 "select first item in pop-up
set completeopt=menuone,menu
set completeopt+=preview
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"------------------------------------------------------------------------------
" Floating Terminal vim8
"------------------------------------------------------------------------------
let g:floaterm_keymap_toggle = '<F12>'
let g:floaterm_width = 0.9
let g:floaterm_height = 0.9
let g:floaterm_wintype = 'float'
" Set floaterm window's background to black
hi Floaterm guibg=black
" " Set floating window border line color to cyan, and background to orange
hi FloatermBorder guibg=orange guifg=cyan
"------------------------------------------------------------------------------
" CCTree database handling functions
"------------------------------------------------------------------------------
function! RefreshCCTree()
CCTreeUnLoadDB
!rm -f cctree.lst
call LoadCCTree()
endfunc
function! LoadCCTree()
if filereadable('cctree.lst')
CCTreeLoadXRefDBFromDisk cctree.lst
else
if filereadable('cscope.out')
CCTreeLoadDB cscope.out
CCTreeSaveXRefDB cctree.lst
endif
endif
endfunc
" C src code & header
autocmd bufnewfile *.c so ~/.vim/headers/c_header.template
autocmd bufnewfile *.c exe "1," . 12 . "g/File Name :.*/s//File Name : " .expand("%")
autocmd bufnewfile *.c exe "1," . 12 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%y %H:%M:%S")
autocmd Bufwritepre,filewritepre *.c execute "normal ma"
autocmd Bufwritepre,filewritepre *.c exe "1," . 12 . "g/Last Modified :.*/s//Last Modified : " .strftime("%d-%m-%y %H:%M:%S")
autocmd bufwritepost,filewritepost *.c execute "normal `a"
autocmd bufnewfile *. so ~/.vim/headers/c_header.template
autocmd bufnewfile *.h exe "1," . 12 . "g/File Name :.*/s//File Name : " .expand("%")
autocmd bufnewfile *.h exe "1," . 12 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%y %H:%M:%S")
autocmd Bufwritepre,filewritepre *.h execute "normal ma"
autocmd Bufwritepre,filewritepre *.h exe "1," . 12 . "g/Last Modified :.*/s//Last Modified : " .strftime("%d-%m-%y %H:%M:%S")
autocmd bufwritepost,filewritepost *.h execute "normal `a"
" Sh code header
autocmd bufnewfile *.sh so ~/.vim/headers/sh_header.template
autocmd bufnewfile *.sh exe "1," . 15 . "g/Script Name :.*/s//Script Name : " .expand("%")
autocmd bufnewfile *.sh exe "1," . 15 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%y %H:%M:%S")
autocmd Bufwritepre,filewritepre *.sh execute "normal ma"
autocmd Bufwritepre,filewritepre *.sh exe "1," . 15 . "g/Last Modified :.*/s//Last Modified : " .strftime("%d-%m-%y %H:%M:%SS")
autocmd bufwritepost,filewritepost *.sh execute "normal `a"