-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
306 lines (251 loc) · 8.23 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
set nocompatible
set term=screen-256color
set rtp+=~/.vim/bundle/vundle/
set encoding=utf-8
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'https://github.com/scrooloose/nerdtree'
Bundle 'taglist.vim'
Bundle 'https://github.com/honza/vim-snippets'
Bundle 'https://github.com/sirver/UltiSnips'
Bundle 'https://github.com/vim-airline/vim-airline'
Bundle 'https://github.com/kien/ctrlp.vim'
Bundle 'https://github.com/Raimondi/delimitMate'
Bundle 'https://github.com/tpope/vim-surround'
Bundle 'https://github.com/jreybert/vimagit'
Bundle 'https://github.com/AndrewRadev/quickpeek.vim'
Bundle 'https://github.com/skywind3000/vim-quickui'
Bundle 'https://github.com/tomasiser/vim-code-dark'
Bundle 'The-NERD-Commenter'
Bundle 'https://github.com/frazrepo/vim-rainbow'
Bundle 'https://github.com/Yggdroot/indentLine'
Bundle 'https://github.com/github/copilot.vim'
Bundle 'https://github.com/godlygeek/tabular'
Bundle 'https://github.com/vim-scripts/LargeFile'
if has ("syntax")
syntax on
endif
filetype detect
set autoindent
set ts=4
set expandtab
set shiftwidth=4
" 使用>> << 和 ctrl-T ctrl-D 0 ctrl-D 来缩进和反缩进
set nowrap
set hlsearch
set backspace=indent,eol,start whichwrap+=<,>,[,]
set ofu=syntaxcomplete#Complete
set mouse=
" option for foldmethod
set fdm=marker
set foldcolumn=2
"colorscheme molokai
colorscheme codedark
" xiongkun added in 2021 year
map gs :update<cr>
nn <up> <C-u>
nn <down> <C-d>
" nmap o i<cr>
" options for delimitMate
let delimitMate_expand_cr = 1
let delimitMate_expand_space = 1
map <left> :tabp <cr>
map <right> :tabn <cr>
let g:ctrlp_working_path_mode = 'r'
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/build/*,*.pyc*,*.swp*,*.swo*,*/build_*/* " Linux/MacOSX
set undofile
set undodir=/tmp/
set grepprg=egrep\ -n\ $*
let g:ctrlp_extensions = ['tag', 'line' ]
set scrolloff=8
set autoread
set autowrite
set mps+=<:>
set highlight=v:Error
" xiongkun defined function for cpp or python
fu! SelectAugment()
" always exclusive; bacause we don't want to delete a argument
let save_cursor = getcurpos()
let save_register_s = getpos("'s")
let save_register_e = getpos("'e")
let start_cursor = deepcopy(save_cursor)
let end_cursor = deepcopy(save_cursor)
let [line, col] = searchpairpos('(', ',', ')', 'b')
let start_cursor[1] = line
let start_cursor[2] = col
call setpos("'s", start_cursor)
call setpos("." , save_cursor)
let [line, col] = searchpairpos('(', ',', ')')
let end_cursor[1] = line
let end_cursor[2] = col
call setpos("'e", end_cursor)
normal! `slv`eh
call setpos("'s", save_register_s)
call setpos("'e", save_register_e)
endf
fu! SelectUnderlineWord()
execute "keepjump normal! ?[^a-zA-Z]\r:nohlsearch\rlvN"
endf
" select a augment in functions: func(arg1, arg2, args4, call(123)) , when cursor in args1, select the args1
onoremap aa :<c-u>call SelectAugment()<cr>
" select a word between _. _first_second_third_ , if cursor in second, then select the second.
onoremap au :<c-u>call SelectUnderlineWord()<cr>
" ugly here
nnoremap <space>e :<c-u>execute "normal!" "?{}\\\\|()\\\\|[]\r:nohlsearch\r" <cr>
" Shot key for copy: disable the mouse and enable the mouse
cabbr vem set mouse=a
cabbr vdm set mouse=
cabbr vex <c-r>=expand('<cword>')<cr>
" Repace Operator, replace text with "0 register. (last yank)
nmap <silent> cr :set opfunc=CountSpaces<CR>g@
vmap <silent> <space>r :<C-U>call CountSpaces(visualmode(), 1)<CR>
function! CountSpaces(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:0 " Invoked from Visual mode, use gv command.
silent exe "normal! gvd\"0P"
elseif a:type == 'line'
silent exe "normal! '[d']\"0Po\<esc>"
"echom "Not Support LineWise for <space>r operator"
else
silent exe "normal! `[d`]x\"0P"
endif
let &selection = sel_save
let @@ = reg_save
endfunction
""" Add () surround motion operator
nmap <silent> <space>b :set opfunc=SurroundWithBrace<CR>g@
vmap <silent> <space>b :<C-U>call SurroundWithBrace(visualmode(), 1)<CR>
function! SurroundWithBrace(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
let old_s_pos = getpos("'s")
let old_e_pos = getpos("'e")
let start_pos = getpos("'[")
let end_pos = getpos("']")
call setpos("'s", start_pos)
call setpos("'e", end_pos)
if a:0 " Invoked from Visual mode, use gv command.
echom "Not Support Visual Mode for <space>( operator"
"silent exe "normal! gvd\"0P"
elseif a:type == 'line'
silent exe "normal! 'ea)\<esc>'si(\<esc>"
else
silent exe "normal! `ea)\<esc>`si(\<esc>"
endif
let &selection = sel_save
let @@ = reg_save
call setpos("'s", old_s_pos)
call setpos("'e", old_e_pos)
endfunction
""" variable for ultisnips
let g:UltiSnipsExpandTrigger = '<c-j>'
let g:UltiSnipsJumpForwardTrigger='<c-j>'
let g:UltiSnipsJumpBackwardTrigger='<c-k>'
"""" YCM config
"let g:ycm_python_binary_path = '/usr/bin/python3'
"let g:ycm_server_python_interpreter = '/usr/bin/python2'
""" VimEnter
autocmd BufEnter * source ~/.vim/after/keymap.vim
if ($VIMCODE == "ON")
augroup VIMCODE_INIT
autocmd!
augroup END
echo "starting VIMCODE MODE..."
endif
if !(&diff) && ($VIMCODE != "ON")
augroup NERDTREE
autocmd!
autocmd VimEnter * NERDTreeToggle | wincmd w
augroup END
endif
if filereadable(expand("~/.xkconfig.vim"))
autocmd VimEnter * source ~/.xkconfig.vim
endif
""" pdf for vim
abbre xkpdb breakpoint()
let mapleader='\'
set runtimepath+=$HOME/.vim/plugin/xiongkun/plugin
set shell=bash
set path+='./'
set cursorline
set tags+=$HOME/cpp_src/stl.tags
""" configure for quick-peek plugin
let g:quickpeek_auto = v:true
set completeopt=menu,preview
" Open filetype plugin, you can use the quickpeek plugin
filetype plugin on
""" configure for g:UltiSnippetEdit
let g:home=$HOME
let g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit=g:home."/xkvim/xiongkun/plugin/UltiSnips/"
""" universe reflesh
function! UniverseReflesh()
call UltiSnips#RefreshSnippets()
endfunction
nmap <F9> :call UniverseReflesh()<cr>
let g:ctrlp_by_filename = 1 "default by filename mode for speed."
nmap <leader><M-m> :tabe<cr>\M
let NERDTreeIgnore = ['\.pyc$', 'user_tag', '\.aux', '\.out', '\.log', '\.pdf'] " 过滤所有.pyc文件不显示
let g:netrw_ftp_list_cmd = "ls"
let g:netrw_ftp_cmd="ftp -p "
abbre fftp ftp://10.255.129.13:8081/
"set foldopen=hor,search,jump,block,mark,quickfix
"set foldclose=all
hi CursorLine term=bold ctermbg=240
"hi CursorLine term=bold ctermbg=24 guibg=#13354A
let g:current_branch = trim(system("git symbolic-ref --short HEAD 2>/dev/null"))
function! MyPlugin(...)
let branch=""
if !(&diff) " add branch information. 2022/5/19
let branch = g:current_branch
endif
let w:airline_section_b = branch
endfunction
call airline#add_statusline_func('MyPlugin')
" Go to the last position.
" autocmd BufEnter * silent! normal! g`"zz
set noshowmode
set termwinscroll=100000
let delimitMate_matchpairs = "(:),[:],{:}"
" set switchbuf=vsplit
let g:surround_no_mappings=1
hi TabLineSel term=reverse cterm=undercurl ctermfg=203 ctermbg=234 gui=undercurl guifg=#F44747 guibg=#1E1E1E guisp=#F44747
" rainbow plugin config:
" let g:rainbow_active = 1
set incsearch
source $HOME/xkvim/coc.vim
set nofoldenable
" paste and brakets
" http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x
" then https://coderwall.com/p/if9mda
" and then https://github.com/aaronjensen/vimfiles/blob/59a7019b1f2d08c70c28a41ef4e2612470ea0549/plugin/terminaltweaks.vim
" to fix the escape time problem with insert mode.
"
" Docs on bracketed paste mode:
" http://www.xfree86.org/current/ctlseqs.html
" Docs on mapping fast escape codes in vim
" http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim
if exists("g:loaded_bracketed_paste")
finish
endif
let g:loaded_bracketed_paste = 1
let &t_ti .= "\<Esc>[?2004h"
let &t_te = "\e[?2004l" . &t_te
function! XTermPasteBegin(ret)
set pastetoggle=<f29>
set paste
return a:ret
endfunction
execute "set <f28>=\<Esc>[200~"
execute "set <f29>=\<Esc>[201~"
map <expr> <f28> XTermPasteBegin("i")
imap <expr> <f28> XTermPasteBegin("")
vmap <expr> <f28> XTermPasteBegin("c")
cmap <f28> <nop>
cmap <f29> <nop>
tmap <f28> <nop>
tmap <f29> <nop>
" to avoid abandom
set hidden