-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc_for_server
418 lines (365 loc) · 11.4 KB
/
.vimrc_for_server
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
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
source $VIMRUNTIME/mswin.vim
behave mswin
let mapleader=","
let g:mapleader = ","
let $VIMRC='~/.vimrc'
nmap <leader>v :vi $VIMRC<CR>
" 基本界面配置
set laststatus=2
set t_Co=256
colorscheme molokai2
set number
set relativenumber
set nowrap
set cursorcolumn
set cursorline
set cmdheight=1
set go=
" 缩进配置
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
set cindent
set cino=g0
filetype on
filetype indent on
nnoremap <CR> ==<CR>
" 编码配置
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,iso-2022-jp,Shift_JIS,cp936,gb18030,big5,euc-jp,latin1
set langmenu=zh_CN.utf-8
set helplang=CN
let $LANG = 'en_US.utf-8'
language messages zh_CN.utf-8
" 取消备份及交换文件
set nobackup
set noswapfile
set noundofile
" 禁用<F1>
map <F1> <Esc>
imap <F1> <Esc>
" 禁用蜂鸣警告
set vb t_vb=
" 切换窗口
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" 光标移动增强
nmap H ^
vmap H ^
omap H ^
nmap L $
vmap L $
omap L $
" 插入模式快捷键
imap <C-h> <Left>
imap <C-j> <Down>
imap <C-k> <Up>
imap <C-l> <Right>
imap <C-u> <Esc> u
imap jk <Esc>
" Operator-Pending映射
onoremap in( :<c-u>normal! f(vi(<CR>
onoremap in[ :<c-u>normal! f[vi[<CR>
onoremap in{ :<c-u>normal! f{vi{<CR>
onoremap in< :<c-u>normal! f<vi<<CR>
onoremap in" :<c-u>normal! f"vi"<CR>
onoremap in' :<c-u>normal! f'vi'<CR>
" 代码折叠
set foldenable
set foldmethod=syntax
set foldcolumn=0
set foldlevelstart=99
" 共享系统剪切板
set clipboard=unnamedplus
" 集成终端
set shell=/bin/zsh
" 自动载入
set autoread
set history=200
" 默认工作目录
let $PWD = $HOME . "/Projects"
if isdirectory($PWD)
cd $PWD
endif
" 代码初始化模板
iabbrev shmain+ #!/bin/bash<CR><CR>
iabbrev pymain+ #_*_ coding: utf-8 _*_<CR>
\#!/usr/bin/env python3<CR><CR>
iabbrev rbmain+ #!/usr/bin/env ruby<CR><CR>
augroup code_template
autocmd!
autocmd BufNewFile *.sh :normal ishmain+
autocmd BufNewFile *.py :normal ipymain+
autocmd BufNewFile *.rb :normal irbmain+
augroup END
" 括号自动补全
inoremap ( ()<Esc>i
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap [ []<Esc>i
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap { {}<Esc>i
inoremap } <c-r>=ClosePair('}')<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endfunction
function! QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
return a:char
elseif line[col - 1] == a:char
return "\<Right>"
else
return a:char.a:char."\<Esc>i"
endif
endfunction
" Vim-plug 插件列表
filetype off
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'easymotion/vim-easymotion'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'skywind3000/asyncrun.vim'
Plug 'pbrisbin/vim-mkdir'
Plug 'terryma/vim-multiple-cursors'
Plug 'Yggdroot/indentLine'
Plug 'mhinz/vim-startify'
Plug 'terryma/vim-smooth-scroll'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'neovimhaskell/haskell-vim'
call plug#end()
" EasyMotion
let g:EasyMotion_smartcase = 1
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_startofline = 0
let g:EasyMotion_enter_jump_first = 1
let g:EasyMotion_move_highlight = 0
map / <Plug>(easymotion-sn)
nmap ; <Plug>(easymotion-next)
" 垂直分屏 <F3>
map <silent> <F3> :call VerticalSplit()<CR>
imap <silent> <F3> <Esc> :call VerticalSplit()<CR>
let g:is_vsplit = 0
function! VerticalSplit()
if g:is_vsplit
execute "only"
let g:is_vsplit = 0
else
execute "vsplit"
let g:is_vsplit = 1
endif
endfunction
" 平滑滚屏
noremap <silent> J :call smooth_scroll#down(&scroll, 0, 2)<CR>
noremap <silent> K :call smooth_scroll#up(&scroll, 0, 2)<CR>
" IndentLine
let g:indentLine_char = "\u250A"
let g:indentLine_concealcursor = ''
let g:indentLine_bufNameExclude = ['_.*', 'NERD_tree.*']
" multiple-cursors 多行编辑 <C-(n|p|x)>
set selection=inclusive
let g:multi_cursor_use_default_mapping=1
let g:multi_cursor_quit_key='<CR>'
" NERD_Tree 资源管理器 <F5>
map <silent> <F5> :NERDTreeToggle<CR>
imap <silent> <F5> <Esc> :NERDTreeToggle<CR>
let g:NERDTreeChDirMode = 2
let g:NERDTreeIgnore = ['\.o$', '\.pyc$', '\~$', '\.gif', '\.jpg', '\.png']
let g:NERDTreeMouseMode = 3
let g:NERDTreeQuitOnOpen = 1
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeAutoDeleteBuffer = 1
let g:NERDTreeHijackNetrw = 1
let g:NERDTreeDirArrowExpandable = "\uE5FF"
let g:NERDTreeDirArrowCollapsible = "\uE5FE"
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Nerd_Commenter 注释增强 <Leader>c<Space>
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:NERDAltDelims_java = 1
let g:NERDCommentEmptyLines = 0
let g:NERDTrimTrailingWhitespace = 1
" QuickFix 信息窗口 <F2>
map <silent> <F2> :call QuickfixToggle()<CR>
imap <silent> <F2> <Esc>:call QuickfixToggle()<CR>
let g:quickfix_is_open = 0
let g:quickfix_return_to_window = winnr()
function! QuickfixToggle()
if g:quickfix_is_open
execute g:quickfix_return_to_window . "wincmd w"
execute "cclose"
let g:quickfix_is_open = 0
else
let g:quickfix_return_to_window = winnr()
execute "copen 8 | setl wrap"
let g:quickfix_is_open = 1
endif
endfunction
" AirLine 标签及状态栏 <C-t> <Tab> <Leader>[1-9]
nmap <silent> <C-t> :tabnew<CR>
imap <silent> <C-t> <Esc> :tabnew<CR>
let g:airline_theme="onedark"
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_splits = 0
let g:airline#extensions#tabline#show_buffers = 0
let g:airline#extensions#tabline#alt_sep = 0
let g:airline#extensions#tabline#tab_nr_type = 1
let g:airline#extensions#tabline#show_tab_nr = 0
let g:airline#extensions#tabline#show_tab_type = 0
" let g:airline#extensions#tabline#buffers_label = 'Buffers'
" let g:airline#extensions#tabline#tabs_label = 'Tabs'
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <Tab> <Plug>AirlineSelectNextTab
nmap <S-Tab> <Plug>AirlineSelectPrevTab
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
let g:airline#extensions#tabline#keymap_ignored_filetypes = ['vimfiler', 'nerdtree']
let g:airline#extensions#tabline#buffer_nr_show = 0
let g:airline#extensions#tabline#show_close_button = 0
" let g:airline#extensions#tabline#close_symbol = 'X'
let g:airline#parts#ffenc#skip_expected_string = 'utf-8'
let g:airline#extensions#ale#error_symbol = ' ' " \uF057
let g:airline#extensions#ale#warning_symbol = ' ' " \uF06A
let g:airline#extensions#whitespace#checks = []
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = ''
let g:airline_right_sep = '' " \uE0BA
let g:airline_right_alt_sep = '' " \uE0BB
let g:airline_symbols.branch = '⎇ ' " \u2387
let g:airline_symbols.notexists = '' " \uE710
" Startify 欢迎界面
let g:startify_padding_left = 4
let g:startify_disable_at_vimenter = 0
let g:startify_bookmarks = [
\ '~/.zshrc',
\ '~/.vimrc',
\ '/etc/nginx/nginx.conf',
\ ]
let g:startify_custom_header =
\ "startify#fortune#cowsay('','═','║','╔','╗','╝','╚')"
let g:startify_list_order = [
\ [' Recently Used'],
\ 'files',
\ [' My Bookmarks:'],
\ 'bookmarks',
\ ]
let g:startify_custom_footer =
\ ['', " Happy Viming!!"]
augroup startify
autocmd!
autocmd User Startified nmap <buffer> o <plug>(startify-open-buffers)
autocmd User Startified setlocal cursorline
autocmd VimEnter * let t:startify_new_tab = 1
autocmd BufEnter *
\ if !exists('t:startify_new_tab') && empty(expand('%')) |
\ let t:startify_new_tab = 1 |
\ Startify |
\ endif
augroup END
" 编译及执行命令
augroup compile_command
autocmd!
autocmd FileType c call C_Command()
autocmd FileType cpp,cxx call CPP_Command()
autocmd FileType sh let b:RunCommand = "!bash %"
autocmd FileType python let b:RunCommand = "!python3 %"
autocmd FileType ruby let b:RunCommand = "!ruby %"
autocmd FileType haskell let b:RunCommand = "term ghci %"
autocmd FileType javascript let b:RunCommand = "!node %"
augroup END
function! C_Command() " Use LLVM/Clang Compiler
let b:CompileCommand = "AsyncRun clang -std=c99 -Wall -O1 -c %"
let b:LinkCommand = "!clang ./*.o -o Run"
let b:RunCommand = "!./Run"
map <C-F7> :AsyncRun clang -std=c99 -Wall -g -O1 -c %
map <C-F9> :!clang ./*.o -o Run && time ./Run
endfunction
function! CPP_Command() " Use GCC Compiler
let b:CompileCommand = "AsyncRun g++ -std=c++17 -Wall -O1 -c %"
let b:LinkCommand = "!g++ ./*.o -o Run"
let b:RunCommand = "!./Run"
map <C-F7> :AsyncRun g++ -std=c++17 -Wall -g -O1 -c %
map <C-F9> :!g++ ./*.o -o Run && time ./Run
endfunction
" function! CPP_Command() " Use LLVM/Clang Compiler
" let b:CompileCommand = "AsyncRun clang++ -std=c++1z -stdlib=libc++ -Wall -Weffc++ -O0 -c %"
" let b:LinkCommand = "!clang++ -lc++ -lc++abi ./*.o -o Run"
" let b:RunCommand = '!./Run'
" map <C-F7> :AsyncRun clang++ -std=c++1z -stdlib=libc++ -Weverything -g -O2 -c %
" map <C-F9> :!clang++ -lc++ -lc++abi ./*.o -o Run && ./Run
" endfunction
" AsyncRun(异步编译) <F7> <C-F7>
" 保存并编译生成目标文件
map <silent> <F7> :call AsyncCompile()<CR>
imap <F7> <Esc> <F7>
function! AsyncCompile()
if exists('b:CompileCommand')
silent execute "w"
execute b:CompileCommand
if g:ale#engine#GetLoclist(buffer_number("%")) == []
echo "Compiled Successfully!! o(*≧▽≦)ツ"
else
let g:quickfix_return_to_window = winnr()
execute "copen 8 | setl wrap"
let g:quickfix_is_open = 1
execute g:quickfix_return_to_window . "wincmd w"
endif
else
echo "当前文件并不能编译.. ╮( ̄▽ ̄)╭"
endif
endfunction
" Link & Run <F9> <C-F9>
" 链接当前目录的所有目标文件, 生成可执行文件并运行
map <silent> <F9> :call Link_Run()<CR>
imap <F9> <Esc> <F9>
function! Link_Run()
if g:quickfix_is_open
execute g:quickfix_return_to_window . "wincmd w"
execute "cclose"
let g:quickfix_is_open = 0
endif
if exists('b:LinkCommand')
execute b:LinkCommand
endif
if exists('b:RunCommand')
execute b:RunCommand
echohl WarningMsg | echo "Running Finish! o(*≧▽≦)ツ"
else
echo "不是可执行文件.."
endif
endfunction
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif