-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
244 lines (215 loc) · 6.43 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
set nobackup
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set nu
set autoindent
set cindent
set nocompatible " be iMproved
set backspace=2 " be iMproved
set encoding=UTF-8
" 设置Leader键
let mapleader = "<c-a-f11><c-a-f9>"
" Leader while insert to <alt-,>
imap <a-,> <leader>
nmap , <leader>
" move easy
nnoremap <leader>k <c-u>
nnoremap <leader>j <c-d>
inoremap <leader>k <c-o><c-u>
inoremap <leader>j <c-o><c-d>
nnoremap <A-Up> #
nnoremap <A-Down> *
nnoremap <C-p> #
nnoremap <C-n> *
" save easy
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
" 使用GUI界面时的设置
if has("gui_running")
set guioptions+=c " 使用字符提示框
set cursorline " 突出显示当前行
endif
" My Plugins
call plug#begin()
Plug 'scrooloose/nerdtree'
if has("gui_running")
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
endif
Plug 'kkoomen/vim-doge', { 'do': { -> doge#install() } }
Plug 'mhinz/vim-startify'
Plug 'rust-lang/rust.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'laher/fuzzymenu.vim'
Plug 'frazrepo/vim-rainbow'
Plug 'scrooloose/nerdcommenter'
Plug 'lervag/vimtex'
Plug 'tonsky/firacode'
Plug 'easymotion/vim-easymotion'
" Plug 'vim-denops/denops.vim' " no deno for now
Plug 'altercation/solarized'
Plug 'tpope/vim-fugitive'
Plug 'altercation/vim-colors-solarized'
Plug 'tikhomirov/vim-glsl'
Plug 'beyondmarc/hlsl.vim'
Plug 'azabiong/vim-highlighter'
Plug 'mattesgroeger/vim-bookmarks'
Plug 'github/copilot.vim'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'junegunn/vim-easy-align'
call plug#end()
" for easy align
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)<C-X>
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nnoremap <leader>ea vip<Plug>(EasyAlign)<C-X>
" for cpp highlight
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_member_function_highlight = 1
let g:cpp_posix_standard = 0
" for deoplete
let g:deoplete#enable_at_startup = 1
" for startify
let g:startify_bookmarks = [ '~/vimfiles/vimrc', '~/vimfiles/ideavimrc' ]
let g:startify_skiplist = ['^\\\\*', '://'] " no remote server file
" for deno version check
" let g:denops_disable_version_check=1
" configs for NERDTree
nnoremap <leader>nt :NERDTree<CR>
inoremap <leader>nt <esc>:NERDTree<CR>
" configs for fzf
let g:fzf_preview_window = 'right:50%'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
nnoremap <leader>f :FZF<CR>
nnoremap <leader>l :BLines<CR>
nnoremap <leader>gf :GFiles<CR>
nnoremap <leader>m :Fzm<CR>
nnoremap <leader>mm :Commands<CR>
inoremap <leader>f <esc>:FZF<CR>
inoremap <leader>l <esc>:BLines<CR>
inoremap <leader>gf <esc>:GFiles<CR>
inoremap <leader>m <esc>:Fzm<CR>
inoremap <leader>mm <esc>:Commands<CR>
" usage for nerd commenter
" [count]<leader>c<space> |NERDCommenterToggle|
" usage for easy motion:
" <leader>s
let g:EasyMotion_smartcase = 1
" this is for n characters search
nnoremap <Leader>s <Plug>(easymotion-sn)
inoremap <leader>s <esc><Plug>(easymotion-sn)
" Now, all you need to remember is s and JK motions bindings, and it's good enough to boost your cursor speed!
"vim字体大小
" - font type and size setting.
if has('win32')
set clipboard=unnamed
set guifont=Consolas:h16 " Win32.
elseif has('gui_macvim')
set clipboard=unnamed
set guifont=Monaco:h16 " OSX.
else
set clipboard=unnamedplus
set guifont=Monospace\16 " Linux.
endif
colorscheme solarized
set background=dark
let g:airline_theme='solarized'
let g:airline_solarized_bg='dark'
" Highlighter
let HiSet = '<space>s' " normal, visual
let HiErase = '<space>e' " normal, visual
let HiClear = '<space>c' " normal
let HiFind = '<space>f' " normal, visual
" Bookmark
highlight BookmarkSign ctermbg=NONE ctermfg=160
highlight BookmarkLine ctermbg=194 ctermfg=NONE
let g:bookmark_sign = '♥'
let g:bookmark_highlight_lines = 1
let g:bookmark_auto_close = 1
let g:bookmark_show_toggle_warning = 0
nnoremap <Leader>bb <Plug>BookmarkToggle
nnoremap <Leader>ba <Plug>BookmarkAnnotate
nnoremap <Leader>bs <Plug>BookmarkShowAll
inoremap <Leader>bb <esc><Plug>BookmarkToggle
inoremap <Leader>ba <esc><Plug>BookmarkAnnotate
inoremap <Leader>bs <esc><Plug>BookmarkShowAll
" Code Link
function! CodeLink()
let lnum=line('.')
let fname=expand('%:p')
let lk = "codelink://" . fname . ":" . lnum
echom lk
call setreg('+', lk)
endfunction
nnoremap <leader>url :call CodeLink()<CR>
" for quick perforce reference
function! CopyAbsolutePath()
let fname=expand('%:p')
call setreg('+', fname)
endfunction
nnoremap <leader>pt :call CopyAbsolutePath()<CR>
" cscope config file C:\cscope_db\cs.conf, create if not exist
set cscopetag cscopeverbose
let cs_config = "C:\\cscope_db\\cs.conf"
if filereadable(cs_config)
else
echom "cs_config not exists, create it"
execute '!python ' . $HOME . '\\vimfiles\\cscope_tools.py -init'
endif
" cscope update command, will call the python script
" on windows or Linux
func! CscopeCmds(id, result)
if has('win32')
if a:result == 5
execute '!python ' . $HOME . '\\vimfiles\\cscope_tools.py -update'
elseif a:result == 7
execute '!python ' . $HOME . '\\vimfiles\\cscope_tools.py -mkroot'
elseif a:result == 3
:cs add C:\\cscope_db\\cscope.out
elseif a:result == 6
execute '!python ' . $HOME . '\\vimfiles\\cscope_tools.py -chroot'
elseif a:result == 4
execute '!python ' . $HOME . '\\vimfiles\\cscope_tools.py -files'
elseif a:result == 1
:cs find s <cword>
elseif a:result == 2
:cs find t <cword>
endif
else
" TODO
endif
endfunc
func! CsPopup()
call popup_menu([
\ 'lookup symbol',
\ 'lookup text',
\ 'load',
\ 'select types',
\ 'update',
\ 'choose root',
\ 'make as root',
\ ],
\ #{ title: "Cscope operations", callback: 'CscopeCmds', line: 25, col: 40,
\ highlight: 'Question', border: [], close: 'click', padding: [1,1,0,1]} )
endfunc
nnoremap <leader>mm :call CsPopup()<CR>
nnoremap <leader>db :call CsPopup()<CR>
" add start tag
func! AddStartTag()
let line_content = "// FIFA_BEGIN | DIVERGENCE | kenzhang | " . strftime("%Y-%m-%d") . " | Reason: TODO"
call append(line('.'), line_content)
return
endfunc
nnoremap <leader>ts :call AddStartTag()<CR>
" add end tag
func! AddEndTag()
let line_content = "// FIFA_END"
call append(line('.'), line_content)
return
endfunc
nnoremap <leader>te :call AddEndTag()<CR>