-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimconfig
318 lines (242 loc) · 8.99 KB
/
vimconfig
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
" ----------------------------------------------------------
" +plugin
" ----------------------------------------------------------
call plug#begin('~/.vim/plugged')
" vim function
"
Plug 'mhinz/vim-startify'
Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
Plug 'skywind3000/asynctasks.vim'
Plug 'skywind3000/asyncrun.vim'
Plug 'aperezdc/vim-template'
Plug 'jiangmiao/auto-pairs'
Plug 'scrooloose/syntastic'
" Plug 'skywind3000/vim-rt-format', { 'do': 'pip3 install autopep8' }
" language enhance
"
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'Yggdroot/indentLine'
Plug 'rhysd/vim-clang-format'
Plug 'preservim/tagbar'
call plug#end()
" Plug 'vimwiki/vimwiki'
" Plug 'morhetz/gruvbox'
" Plug 'tomasiser/vim-code-dark'
"Plug 'puremourning/vimspector'
"Plug 'hdima/python-syntax'
"Plug 'tpope/vim-markdown'
"Plug 'iamcco/markdown-preview.nvim'
" ----------------------------------------------------------
" +vim
" ----------------------------------------------------------
set clipboard=unnamed
set encoding=utf8
set number
set relativenumber
set tabstop=4
set expandtab
" setting shift+>
set smartindent
set shiftwidth=4
set showcmd
" set cursorcolumn
set cursorline
hi CursorLine cterm=NONE ctermbg=241 ctermfg=NONE guibg=NONE guifg=NONE
" setting backspace
set backspace=indent,eol,start
"set system clipboard in vim
"set clipboard=unnamedplus
"set clipboard=unnamedplus
syntax on
set dictionary=/usr/share/dict/words
map <C-K> :ClangFormat
imap <C-K> <c-o>:ClangFormat
" ----------------------------------------------------------
" +map
" ----------------------------------------------------------
"
let mapleader = " "
nnoremap <silent><c-e> :NERDTree<CR>
nnoremap <silent><CR> o<ESC>
nnoremap > >>
nnoremap < <<
nnoremap <C-s> :w<CR>
nnoremap <C-q> :q<CR>
nnoremap <leader>xx :bd<CR>
nnoremap <leader>xw :close<CR>
nnoremap <leader>t :botright terminal<CR>
" ----------------------------------------------------------
" +autocmd
" ----------------------------------------------------------
" autocmd BufRead *.cpp RTFormatEnable
" ----------------------------------------------------------
" +markdown
" ----------------------------------------------------------
set nofoldenable
" ----------------------------------------------------------
" +airline
" ----------------------------------------------------------
let g:airline_powerline_fonts = 1
let g:airline_theme = 'simple'
let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#left_sep = ' ' "separater
" let g:airline#extensions#tabline#left_alt_sep = '' "separater
" let g:airline#extensions#tabline#formatter = 'default' "formater
" let g:airline_left_sep = ''
" let g:airline_left_alt_sep = '❯'
" let g:airline_right_sep = ''
" let g:airline_right_alt_sep = '❮'
" function! WindowNumber(...)
" let builder = a:1
" let context = a:2
" call builder.add_section('airline_b', '%{tabpagewinnr(tabpagenr())}')
" return 0
" endfunction
"
" call airline#add_statusline_func('WindowNumber')
" call airline#add_inactive_statusline_func('WindowNumber')
" ====== syntastic setting =====
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
"
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" ----------------------------------------------------------
" +template
" ----------------------------------------------------------
let g:templates_directory = '~/.vim/templates'
" ----------------------------------------------------------
" +coc
" ----------------------------------------------------------
let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-html', 'coc-jedi']
"
" inoremap <expr> <TAB> coc#pum#visible() ? coc#pum#confirm() : "\<TAB>"
"
"=========== coc complete setting ===================
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
"------------------------------------------------
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
"------------------------------------------------
inoremap <silent><expr> <c-o> coc#refresh()
"------------------------------------------------
"------------------------------------------------
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
"------------------------------------------------
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
"------------------------------------------------
" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
"------------------------------------------------
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" ====== vimspector setting===
" let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-cpptools', 'CodeLLDB' ]
" ----------------------------------------------------------
" +highlightcpp
" ----------------------------------------------------------
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_experimental_simple_template_highlight = 1
let g:cpp_experimental_template_highlight = 1
let g:cpp_concepts_highlight = 1
let g:cpp_no_function_highlight = 0
" ----------------------------------------------------------
" +clang-format
" ----------------------------------------------------------
let g:clang_format#style_options = {
\ "AccessModifierOffset" : -4,
\ "AllowShortIfStatementsOnASingleLine" : "true",
\ "AlwaysBreakTemplateDeclarations" : "true",
\ "TabWidth" : 4,
\ "IndentWidth" : 4,
\ "Standard" : "C++11"}
" ----------------------------------------------------------
" +indentLine
" ----------------------------------------------------------
" let g:indentLine_setColors = 0
let g:indentLine_color_term = 239
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
let g:indentLine_enabled=1
let g:indent_guides_guide_size=1 " 指定对齐线的尺寸
let g:indent_guides_start_level=2 " 从第二层开始可视化显示缩进
let g:vim_json_conceal=0
" ----------------------------------------------------------
" +tagbar
" ----------------------------------------------------------
nmap <F2> :TagbarToggle<CR>
" ----------------------------------------------------------
" +autopairs
" ----------------------------------------------------------
let g:AutoPairs = {
\ '(':')',
\ '[':']',
\ '{':'}',
\ "'":"'",
\ '"':'"',
\ "`":"`",
\ '```':'```',
\ '"""':'"""',
\ "'''":"'''",
\ '**':'**'}
" ----------------------------------------------------------
" +asynctasks
" ----------------------------------------------------------
let g:asyncrun_open = 10
nnoremap <leader>b :AsyncTask file-build<cr>
nnoremap <leader>r :AsyncTask file-run<cr>
" ----------------------------------------------------------
" +vim-rt-format
" ----------------------------------------------------------
" By default, it will be triggered by `ENTER` in insert mode.
" set this to 1 to use `CTRL+ENTER` instead, and keep the
" default `ENTER` behavior unchanged.
" let g:rtf_ctrl_enter = 0
" Enable formatting when leaving insert mode
" let g:rtf_on_insert_leave = 1