forked from skywind3000/vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskywind.vim
531 lines (446 loc) · 16.4 KB
/
skywind.vim
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
"----------------------------------------------------------------------
"- Global Settings
"----------------------------------------------------------------------
let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h')
let &tags = './.tags;,.tags,' . expand('~/.vim/tags/standard.tags')
filetype plugin indent on
set hlsearch
set incsearch
set wildmenu
set cpo-=<
noremap <tab>/ :emenu <C-Z>
" noremap <c-n> :emenu <C-Z>
set lazyredraw
set errorformat+=[%f:%l]\ ->\ %m,[%f:%l]:%m
command! -nargs=1 VimImport exec 'so '.s:home.'/'.'<args>'
command! -nargs=1 VimLoad exec 'set rtp+='.s:home.'/'.'<args>'
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE
\ gui=NONE guifg=DarkGrey guibg=NONE
call Backup_Directory()
let g:ycm_goto_buffer_command = 'new-or-existing-tab'
if has('patch-7.4.500') || v:version >= 800
if !has('nvim')
set cryptmethod=blowfish2
endif
endif
if has('nvim')
set guicursor=
endif
"----------------------------------------------------------------------
"- Autocmds
"----------------------------------------------------------------------
augroup SkywindGroup
au!
au User AsyncRunStart call asyncrun#quickfix_toggle(6, 1)
au User VimMakeStart call vimmake#toggle_quickfix(6, 1)
au User VimScope call vimmake#toggle_quickfix(6, 1)
au BufNewFile,BufRead *.as setlocal filetype=actionscript
au BufNewFile,BufRead *.pro setlocal filetype=prolog
au BufNewFile,BufRead *.es setlocal filetype=erlang
au BufNewFile,BufRead *.asc setlocal filetype=asciidoc
au FileType python setlocal shiftwidth=4 tabstop=4 noexpandtab
au FileType lisp setlocal ts=8 sts=2 sw=2 et
au FileType scala setlocal sts=4 sw=4 noet
au FileType haskell setlocal et
augroup END
"----------------------------------------------------------------------
" keymaps
"----------------------------------------------------------------------
if has('win32') || has('win16') || has('win64') || has('win95')
noremap <space>hw :FileSwitch tabe e:/svn/doc/linwei/GTD.otl<cr>
else
endif
"----------------------------------------------------------------------
"- Return last position
"----------------------------------------------------------------------
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
"----------------------------------------------------------------------
"- Vimmake
"----------------------------------------------------------------------
let g:vimmake_run_guess = ['go']
let g:vimmake_ftrun = {}
let g:vimmake_ftrun['make'] = 'make -f'
let g:vimmake_extrun = {'hs': 'runghc', 'lisp': 'sbcl --script'}
let g:vimmake_extrun['scala'] = 'scala'
let g:vimmake_extrun['es'] = 'escript'
let g:vimmake_extrun['erl'] = 'escript'
let g:vimmake_extrun['clj'] = 'clojure'
let g:vimmake_extrun['hs'] = 'runghc'
if has('win32') || has('win64') || has('win16') || has('win95')
let g:vimmake_extrun['scm'] = "d:\\linux\\bin\\guile.exe"
let g:vimmake_extrun['io'] = "d:\\dev\\IoLanguage\\bin\\io.exe"
let g:vimmake_extrun['pro'] = "start d:\\dev\\swipl\\bin\\swipl-win.exe -s"
let g:vimmake_extrun['pl'] = "start d:\\dev\\swipl\\bin\\swipl-win.exe -s"
let g:vimmake_build_encoding = 'gbk'
let g:asyncrun_encs = 'gbk'
let cp = "d:/dev/scala/scala-2.11.6/lib/scala-actors-2.11.0.jar;"
let cp.= "d:/dev/scala/scala-2.11.6/lib/akka-actor_2.11-2.3.4.jar"
let g:vimmake_extrun['scala'] = 'scala'
"let g:vimmake_extrun['scala'].= ' -cp '.fnameescape(cp)
else
if executable('clisp')
let g:vimmake_extrun['lisp'] = 'clisp'
elseif executable('sbcl')
let g:vimmake_extrun['list'] = 'sbcl --script'
endif
if executable('swipl')
let g:vimmake_extrun['pro'] = 'swipl -s'
endif
endif
if has('win32') || has('win64') || has('win16') || has('win95')
let g:vimmake_cflags = ['-O3', '-lwinmm', '-lstdc++', '-lgdi32', '-lws2_32', '-msse3']
else
let g:vimmake_cflags = ['-O3', '-lstdc++']
runtime ftplugin/man.vim
nnoremap K :Man <cword><CR>
let g:ft_man_open_mode = 'vert'
endif
if has('nvim')
let g:asyncrun_trim = 1
let g:vimmake_build_trim = 1
endif
let g:vimmake_mode = {}
for s:i in range(10)
if !has_key(g:vimmake_mode, s:i)
let g:vimmake_mode[s:i] = 'async'
endif
if !has_key(g:vimmake_mode, 'c'.s:i)
let g:vimmake_mode['c'.s:i] = 'async'
endif
endfor
"----------------------------------------------------------------------
" QuickMenu
"----------------------------------------------------------------------
call quickmenu#current(1)
if has('win32') || has('win64') || has('win16') || has('win95')
call quickmenu#append('Win32 Help', 'call menu#WinHelp("d:/dev/help/win32.hlp")', 'Looking up Win32 API')
call quickmenu#append('MSDN of VC6', 'call menu#WinHelp("d:/dev/help/chm/vc.chm")', 'MSDN')
call quickmenu#append('Python2 Help', 'call menu#WinHelp("d:/dev/help/chm/python2713.chm")', 'Python 2 Document')
call quickmenu#append('Python3 Help', 'call menu#WinHelp("d:/dev/help/chm/python362.chm")', 'Python 3 Document')
endif
"----------------------------------------------------------------------
"- OptImport
"----------------------------------------------------------------------
" VimImport site/echofunc.vim
VimImport site/argtextobj.vim
VimImport site/calendar.vim
"VimImport site/hilinks.vim
if has('gui_running')
VimImport site/hexhigh.vim
endif
"----------------------------------------------------------------------
"- OmniCpp
"----------------------------------------------------------------------
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
"----------------------------------------------------------------------
"- neocomplete
"----------------------------------------------------------------------
if 0
let g:acp_enableAtStartup = 0
" 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 dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" 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>"
" 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
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
endif
"----------------------------------------------------------------------
"- netrw / winmanager
"----------------------------------------------------------------------
let s:enter = 0
let g:bufExplorerWidth=26
let g:winManagerWindowLayout = "FileExplorer|TagList"
"let g:winManagerWindowLayout = "FileExplorer|Tagbar"
let g:winManagerWidth=26
"let g:bufferhint_KeepWindow = 1
set completeopt=menu
" let g:tagbar_left = 1
function! Tagbar_Start()
exe 'TagbarOpen'
exe 'q'
endfunction
function! Tagbar_IsValid()
return 1
endfunction
function! WMResize()
FirstExplorerWindow
vertical resize 28
set winfixwidth
wincmd l
endfunc
function! WMFocusEdit(n)
FirstExplorerWindow
wincmd l
if a:n > 0
wincmd l
endif
endfunc
function! WMFocusQuickfix()
exec "FirstExplorerWindow"
exec "wincmd l"
exec "wincmd j"
endfunc
function! s:TbInit()
if !filereadable(expand('~/.vim/tabbar2.vim'))
return 0
endif
source ~/.vim/tabbar2.vim
exec 'TbStart'
exec 'wincmd j'
return 1
endfunc
"----------------------------------------------------------------------
"- ToggleDevelop
"----------------------------------------------------------------------
function! ToggleDevelop(layout)
if s:enter == 0
"set showtabline=2
set equalalways
let s:enter = 1
endif
set equalalways
if a:layout == 0
set nonumber
exec 'copen 6'
wincmd j
set winfixheight
wincmd k
exec 'wincmd l'
exec 'WMToggle'
exec 'wincmd l'
let s:screenw = &columns
let s:screenh = &lines
let s:size = (s:screenw - 28) / 2
exec 'set number'
call WMResize()
if s:size >= 65
exec 'vs'
exec 'wincmd h'
exec 'wincmd h'
exec 'vertical resize 28'
set winfixwidth
exec 'wincmd l'
exec 'vertical resize ' . s:size
endif
"let s:enter = 1
elseif a:layout == 1 || a:layout == 2
set nonumber
exec 'copen 6'
wincmd j
set winfixheight
wincmd k
exec 'wincmd l'
exec 'WMToggle'
exec 'wincmd l'
exec 'TagbarOpen'
call WMResize()
exec 'wincmd l'
exec 'wincmd l'
exec 'vertical resize 28'
set winfixwidth
exec 'wincmd h'
set number
let s:size = (&columns - 58)
exec 'vertical resize ' . s:size
if a:layout == 2
if s:TbInit()
set showtabline=1
endif
endif
elseif a:layout == 3 || a:layout == 4
set nonumber
copen 6
wincmd j
set winfixheight
wincmd k
TagbarOpen
wincmd l
vertical resize 28
wincmd h
set number
if a:layout == 4
vs
wincmd h
set winfixwidth
endif
endif
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
endfunc
noremap <leader>f1 :FirstExplorerWindow<cr>
noremap <leader>f2 :BottomExplorerWindow<cr>
noremap <leader>f3 :call WMFocusEdit(0)<cr>
noremap <leader>f4 :call WMFocusEdit(1)<cr>
noremap <leader>f0 :call WMFocusQuickfix()<cr>
noremap <leader>fm :call ToggleDevelop(0)<cr>
noremap <leader>fn :call ToggleDevelop(1)<cr>
noremap <leader>fs :call ToggleDevelop(3)<cr>
noremap <leader>fd :call ToggleDevelop(4)<cr>
noremap <leader>fb :call ToggleDevelop(2)<cr>
noremap <leader>fa :TagbarOpen<cr>
noremap <leader>fc :Calendar<cr>
noremap <leader>ft :NERDTree<cr>:vertical resize +3<cr>
"----------------------------------------------------------------------
"- bufferhint
"----------------------------------------------------------------------
nnoremap - :call bufferhint#Popup()<CR>
nnoremap <leader>p :call bufferhint#LoadPrevious()<CR>
let g:bufferhint_CustomHighlight = 1
hi! default link KeyHint Statement
hi! default link AtHint Identifier
"----------------------------------------------------------------------
" Enable vim-diff-enhanced (Christian Brabandt)
"----------------------------------------------------------------------
function! EnableEnhancedDiff()
let &diffexpr='EnhancedDiff#Diff("git diff", "--diff-algorithm=patience")'
endfunc
if executable('git')
let &diffexpr='EnhancedDiff#Diff("git diff", "--diff-algorithm=patience")'
endif
command! -bang -nargs=* -complete=file Make VimMake -program=make @ <args>
"----------------------------------------------------------------------
" netrw syntax
"----------------------------------------------------------------------
" reset netrw's special
function! s:netrw_special()
hi netrwCompress term=NONE cterm=NONE gui=NONE ctermfg=10 guifg=green ctermbg=0 guibg=black
hi netrwData term=NONE cterm=NONE gui=NONE ctermfg=9 guifg=blue ctermbg=0 guibg=black
hi netrwHdr term=NONE cterm=NONE,italic gui=NONE guifg=SeaGreen1
"hi! default link netrwHdr Float
hi netrwLex term=NONE cterm=NONE,italic gui=NONE guifg=SeaGreen1
hi netrwYacc term=NONE cterm=NONE,italic gui=NONE guifg=SeaGreen1
hi netrwLib term=NONE cterm=NONE gui=NONE ctermfg=14 guifg=yellow
hi netrwObj term=NONE cterm=NONE gui=NONE ctermfg=12 guifg=red
hi netrwTilde term=NONE cterm=NONE gui=NONE ctermfg=12 guifg=red
hi netrwTmp term=NONE cterm=NONE gui=NONE ctermfg=12 guifg=red
hi netrwTags term=NONE cterm=NONE gui=NONE ctermfg=12 guifg=red
hi netrwDoc term=NONE cterm=NONE gui=NONE ctermfg=220 ctermbg=27 guifg=yellow2 guibg=Blue3
hi netrwSymLink term=NONE cterm=NONE gui=NONE ctermfg=220 ctermbg=27 guifg=grey60
endfunc
function! s:netrw_highlight()
if !exists('g:netrw_special_syntax') || g:netrw_special_syntax == 0
return
endif
redir => x
silent color
redir END
syn match netrwCpp "\(\S\+ \)*\S\+\.\%(c\|cpp\|m\|cc\|mm\|cxx\)\>" contains=netrwTreeBar,@NoSpell
syn match netrwSrc "\(\S\+ \)*\S\+\.\%(py\|pyw\|java\|s\|asm\|vim\)\>" contains=netrwTreeBar,@NoSpell
if x =~ 'seoul256xxxx'
hi! default link netrwHdr Conditional
hi! default link netrwCpp Repeat
else
let mode = 1
if mode == 3 && &t_Co == 16 | let mode = 2 | endif
if mode == 0
hi netrwHdr term=NONE cterm=NONE gui=NONE ctermfg=7 guifg=#c0c0c0
hi netrwCpp term=NONE cterm=NONE gui=NONE ctermfg=7 guifg=#c0c0c0
hi netrwSrc term=NONE cterm=NONE gui=NONE ctermfg=7 guifg=#c0c0c0
elseif mode == 1
if &t_Co != 256
hi netrwHdr term=NONE cterm=NONE gui=NONE ctermfg=15 guifg=#f8f8f8
hi netrwCpp term=NONE cterm=NONE gui=NONE ctermfg=15 guifg=#f8f8f8
hi netrwSrc term=NONE cterm=NONE gui=NONE ctermfg=15 guifg=#f8f8f8
else
hi netrwHdr term=NONE cterm=NONE gui=NONE ctermfg=255 guifg=#f8f8f8
hi netrwCpp term=NONE cterm=NONE gui=NONE ctermfg=255 guifg=#f8f8f8
hi netrwSrc term=NONE cterm=NONE gui=NONE ctermfg=255 guifg=#f8f8f8
endif
elseif mode == 2
hi netrwHdr term=NONE cterm=NONE gui=NONE ctermfg=10 guifg=green
hi netrwCpp term=NONE cterm=NONE gui=NONE ctermfg=10 guifg=green
hi netrwSrc term=NONE cterm=NONE gui=NONE ctermfg=10 guifg=green
elseif mode == 3
hi netrwHdr term=NONE cterm=NONE gui=NONE ctermfg=117 guifg=#87ceeb
hi netrwCpp term=NONE cterm=NONE gui=NONE ctermfg=117 guifg=#87ceeb
hi netrwSrc term=NONE cterm=NONE gui=NONE ctermfg=117 guifg=#87ceeb
endif
hi netrwData term=NONE cterm=NONE gui=NONE ctermfg=9 guifg=blue
hi netrwLib term=NONE cterm=NONE gui=NONE ctermfg=13 guifg=magenta
hi netrwDoc term=NONE cterm=NONE gui=NONE ctermfg=11 guifg=yellow2
hi netrwObj term=NONE cterm=NONE gui=NONE ctermfg=8 guifg=#808080
hi netrwCompress term=NONE cterm=NONE gui=NONE ctermfg=11 guifg=yellow
hi netrwTilde term=NONE cterm=NONE gui=NONE ctermfg=12 guifg=red
hi netrwTmp term=NONE cterm=NONE gui=NONE ctermfg=12 guifg=red
hi netrwSymLink term=NONE cterm=NONE gui=NONE ctermfg=220 ctermbg=27 guifg=grey60
endif
endfunc
map <leader><F3> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
augroup ThemeUpdateGroup
au!
"au Syntax netrw call s:netrw_highlight()
"au ColorScheme * GuiThemeHighlight
augroup END
let g:solarized_termcolors=256
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
nnoremap <leader><F1> :call Tools_ProfileStart('~/.vim/profile.log')<cr>
nnoremap <leader><F2> :call Tools_ProfileStop()<cr>