-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal_init.vim
More file actions
291 lines (252 loc) · 9.92 KB
/
local_init.vim
File metadata and controls
291 lines (252 loc) · 9.92 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
"----------------------------------------------------
" Setting for visual {
"----------------------------------------------------
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
if 1
set background=dark
colorscheme solarized8_high
"colorscheme solarized8_flat
"let g:solarized_termtrans = 1
let g:solarized_visibility = 'high'
elseif 1
colorscheme one
let g:one_allow_italics = 1
set background=dark
colorscheme one
endif
if exists('g:colors_name')
if g:colors_name == 'solarized8_flat'
" from solarized8
highlight CursorLine cterm=None gui=None ctermbg=236 guibg=#073642 guisp=#eee8d5
endif
endif
set cursorline
"let g:airline#extensions#wordcount#enabled = 0
let g:airline#extensions#tagbar#enabled = 0
let g:airline_powerline_fonts = 1
if exists('g:colors_name')
if g:colors_name =~ 'solarized'
let g:airline_theme='base16_solarized'
"let g:airline_theme='solarized'
"let g:airline_solarized_bg='dark'
elseif g:colors_name =~ 'molokai'
let g:airline_theme='molokai'
elseif g:colors_name =~ 'one'
let g:airline_theme='one'
else
let g:airline_theme='one'
endif
endif
"autocmd BufReadPost * :DetectIndent
let g:sleuth_automatic = 1
let g:indentLine_enabled = 0
let g:indentLine_concealcursor = 'inc'
let g:indentLine_conceallevel = 2
let g:indentLine_char = '┆›┆│|⎸▏' " only first charactor has effect
let g:indentLine_setColors = 1
let g:indentLine_color_gui = '#073642'
"LineNR guifg=#657b83 guibg=#073642
let g:indentLine_color_term = 236
let g:indentLine_bgcolor_term = 'NONE'
let g:indentLine_bgcolor_gui = 'NONE'
if g:indentLine_enabled == 1
set list lcs=tab:\|\
set list lcs=tab:\›\
endif
let g:indentguides_spacechar = '┆'
let g:indentguides_tabchar = '›'
let g:indentguides_conceal_color = 'ctermfg=236 guifg=#073642'
highlight Conceal ctermfg=243 guifg=#657b83
"}
"----------------------------------------------------
" Setting for autoread {
"----------------------------------------------------
" Triger `autoread` when files changes on disk
" https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
" https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
"autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
autocmd FocusGained,BufEnter * if mode() != 'c' | checktime | endif
" Notification after file change
" https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
"}
"----------------------------------------------------
" Setting for Navigation {
"----------------------------------------------------
" c.vim : disable for nativation between panes(windows)
let g:C_Ctrl_j = 'off'
" NERDTree : Disalbe Ctrl + j/k for pane navigation
let g:NERDTreeMapJumpNextSibling = 'J'
let g:NERDTreeMapJumpPrevSibling = 'K'
" }
"----------------------------------------------------
" Setting for source search {
"----------------------------------------------------
" add more options to ctags, including line number
"let g:gutentags_ctags_extra_args = [ '--fields=+niSz' ]
let g:gutentags_ctags_extra_args = [ '--fields=+n' ]
" enable gtags module
let g:gutentags_modules = ['ctags', 'gtags_cscope']
" config project root markers.
let g:gutentags_project_root = ['.root']
" generate datebases in my cache directory, prevent gtags files polluting my project
let g:gutentags_cache_dir = expand('~/.cache/tags')
" forbid gutentags adding gtags databases
let g:gutentags_auto_add_gtags_cscope = 1
let g:gutentags_ctags_exclude = []
"}
"----------------------------------------------------
" Setting for undo tree {
"----------------------------------------------------
if has("persistent_undo")
set undodir=~/.undodir/
set undofile
let g:undotree_SetFocusWhenToggle = 1
nnoremap <F5> :UndotreeToggle<cr>
endif
" }
"----------------------------------------------------
" Setting for NERD tree {
"----------------------------------------------------
function! s:myNERDTreeSwitch( cmd )
let s:bufname = expand('%')
let s:bufpath = expand('%:p')
let s:bufexist = filereadable( s:bufpath )
if s:bufname =~ 'NERD_tree'
execute 'wincmd p'
elseif empty( s:bufname ) == 1 || s:bufexist == 0 "emtpy or not exist
execute 'NERDTreeFocus'
else
execute a:cmd
endif
endfunction
nnoremap <silent> <F2> :call <sid>myNERDTreeSwitch('NERDTreeFind')<CR>
nnoremap <silent> <F3> :call <sid>myNERDTreeSwitch('NERDTreeFocus')<CR>
" }
"----------------------------------------------------
" Setting for Tab/Buffer Control {
"----------------------------------------------------
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <silent> <leader><Tab> :Bdelete<CR>
nmap <silent> <Tab> <Plug>AirlineSelectNextTab<CR>
nmap <silent> <S-Tab> <Plug>AirlineSelectPrevTab<CR>
" }
"----------------------------------------------------
" Setting for deoplete {
"----------------------------------------------------
"inoremap <expr><tab> pumvisible() ? "\<C-n>" : "\<TAB>"
"inoremap <expr><s-tab> pumvisible() ? "\<C-p>" : "\<TAB>"
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
imap <expr><TAB>
\ pumvisible() ? "\<C-n>" :
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
imap <expr><S-TAB>
\ pumvisible() ? "\<C-p>" :
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<S-TAB>"
imap <expr><CR>
\ pumvisible() ? neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand)" : "\<C-Y>" : "\<CR>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
function g:Multiple_cursors_before()
call deoplete#custom#buffer_option('auto_complete', v:false)
endfunction
function g:Multiple_cursors_after()
call deoplete#custom#buffer_option('auto_complete', v:true)
endfunction
" }
"----------------------------------------------------
" Setting for windresizer {
"----------------------------------------------------
let g:winresizer_start_key="<C-w>e"
" }
"----------------------------------------------------
" Setting for search {
"----------------------------------------------------
nmap / <Plug>(incsearch-forward)
nmap ? <Plug>(incsearch-backward)
nmap g/ <Plug>(incsearch-stay)
nmap <space>/ <Plug>(easymotion-sn)
omap <space>/ <Plug>(easymotion-tn)
nmap z? <Plug>(incsearch-fuzzy-?)
nmap z/ <Plug>(incsearch-fuzzy-stay)
nnoremap <Esc><Esc> :<C-u>nohlsearch<CR>
" }
"----------------------------------------------------
" Setting mouse
"----------------------------------------------------
set mouse=n
"----------------------------------------------------
" Setting for smooth/animated scroll
"----------------------------------------------------
"" Plug 'terryma/vim-smooth-scroll'
"nnoremap <silent> <c-u> :call smooth_scroll#up(&scroll, 0, 2)<CR>
"nnoremap <silent> <c-d> :call smooth_scroll#down(&scroll, 0, 2)<CR>
"nnoremap <silent> <c-b> :call smooth_scroll#up(&scroll*3/2, 0, 4)<CR>
"nnoremap <silent> <c-f> :call smooth_scroll#down(&scroll*3/2, 0, 4)<CR>
"" Plug 'yuttie/comfortable-motion.vim'
let g:comfortable_motion_friction = 400.0
let g:comfortable_motion_air_drag = 0.0
"unlet g:comfortable_motion_no_default_key_mappings
let g:comfortable_motion_impulse_multiplier = 1 " Feel free to increase/decrease this value.
"nnoremap <silent> <C-d> :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) / 2)<CR>
"nnoremap <silent> <C-u> :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) / -2)<CR>
"nnoremap <silent> <C-f> :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 4.0)<CR>
"nnoremap <silent> <C-b> :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -4.0)<CR>
nnoremap <silent> <C-d> :call comfortable_motion#flickDist( winheight(0) * 0.9 / 2)<CR>
nnoremap <silent> <C-u> :call comfortable_motion#flickDist( winheight(0) * 0.9 / -2)<CR>
nnoremap <silent> <C-f> :call comfortable_motion#flickDist( winheight(0) * 0.9 )<CR>
nnoremap <silent> <C-b> :call comfortable_motion#flickDist( winheight(0) * 0.9 * -1 )<CR>
vnoremap <silent> <c-u> <c-u>zz
vnoremap <silent> <c-d> <c-d>zz
vnoremap <silent> <c-b> <c-b>zz
vnoremap <silent> <c-f> <c-f>zz
let g:detectindent_preferred_expandtab = 1
let g:detectindent_preferred_indent = 4
let g:detectindent_preferred_when_mixed = 1
let g:detectindent_max_lines_to_analyse = 1024
"----------------------------------------------------
" Setting for redraw/refresh
"----------------------------------------------------
let g:gitgutter_max_signs = 20000
set updatetime=100 "for faster update
"----------------------------------------------------
" Setting for GUI
"----------------------------------------------------
if has("gui_running")
set guifont=D2Coding\ 10
set lines=50
set columns=200
endif
"----------------------------------------------------
" Rearrange Remaps
"----------------------------------------------------
unmap <leader>b
nnoremap <silent> <leader>bb :Buffers<CR>
" Search related mapping
nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext
nmap <Plug>IgnoreMarkSearchPrev <Plug>MarkSearchPrev
map * <Plug>(asterisk-z*)
map # <Plug>(asterisk-z#)
map g* <Plug>(asterisk-gz*)
map g# <Plug>(asterisk-gz#)
let g:syntastic_mode_map = { "mode": "active", "passive_filetypes": ["c", "cpp"] }
let g:syntastic_auto_loc_list = 0 " do not auto popup of location buffer of errors. Use Errors
let g:gutentags_define_advanced_commands = 1
set secure
set exrc
" q never close last window
" q! will close last window
" q! --> close! -> q!
cabbrev wq <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'write \| close' : 'wq')<CR>
cabbrev q <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'close' : 'q')<CR>
cabbrev close! q!