-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
executable file
·528 lines (425 loc) · 13.7 KB
/
vimrc
File metadata and controls
executable file
·528 lines (425 loc) · 13.7 KB
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
" ==========================================
" Sections:
" -> Plugin Management 插件管理
" -> Plugin Settings 插件设置
"
" -> Initial Plugin 加载插件
" -> General Settings 基础设置
" -> Display Settings 展示/排版等界面格式设置
" -> FileEncode Settings 文件编码设置
" -> Others 其它配置
" -> HotKey Settings 自定义快捷键
" -> FileType Settings 针对文件类型的设置
" -> Theme Settings 主题设置
"
" ==========================================
" ==========================================
" Plugin Management 插件管理
" ==========================================
" ################### 包依赖 #####################
" package dependence: ctag, brew install ctags-exuberant
" python dependence: pep8, pyflake
" youcompleteme dependence: cmake
" Plug Settings
" IMPORTANT: Source vim-plug BEFORE the vim9script directive
" This ensures plug.vim is loaded in the traditional VimL context first.
" Ensure this path matches where plug.vim is located on your system.
" For most installations, it's ~/.vim/autoload/plug.vim
source ~/.vim/autoload/plug.vim
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree', {'do': ':NERDTreeToggle'}
Plug 'liuchengxu/vista.vim'
Plug 'raimondi/delimitmate'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': ':CocInstall coc-snippets coc-pyright coc-go coc-tsserver coc-rust-analyzer coc-json coc-html coc-css'}
Plug 'terryma/vim-multiple-cursors'
Plug 'elzr/vim-json'
Plug 'ekalinin/dockerfile.vim'
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'voldikss/vim-floaterm'
Plug 'tpope/vim-fugitive'
" Plug 'neomake/neomake'
" python
Plug 'vim-python/python-syntax'
" javascript
" Plug 'othree/yajs.vim'
" Plug 'pangloss/vim-javascript'
" Plug 'othree/javascript-libraries-syntax.vim'
" html
" Plug 'othree/html5.vim'
" toml
Plug 'cespare/vim-toml'
" hive
Plug 'autowitch/hive.vim'
" scheme
Plug 'altercation/vim-colors-solarized'
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tomasr/molokai'
Plug 'mhinz/vim-startify'
Plug 'morhetz/gruvbox'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
call plug#end()
" ==========================================
" Plugin Settings 插件设置
" ==========================================
" ################### Quick Navigation ###################
" NERDTree
nmap <F2> <Cmd>NERDTreeToggle<CR>
let g:NERDTreeHighlightCursorline = 1
let g:NERDTreeIgnore = [ '\.pyc$', '\.pyo$', '\.obj$', '\.o$', '\.so$', '\.egg$', '^\.git$', '^\.svn$', '^\.hg$', '__pycache__' ]
" Vista
nmap <F9> <Cmd>Vista!!<CR>
function! NearestMethodOrFunction()
return get(b:, 'vista_nearest_method_or_function', '')
endfunction
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
let g:vista_default_executive = 'ctags'
let g:vista_executive_for = {
\ 'cpp': 'vim_lsp',
\ 'php': 'vim_lsp',
\ }
let g:vista_ctags_cmd = {
\ 'haskell': 'hasktags -x -o - -c',
\ }
let g:vista_fzf_preview = ['right:50%']
let g:vista#renderer#enable_icon = 0
set statusline+=%{NearestMethodOrFunction()}
autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
" Coc vim
set nobackup
set nowritebackup
set updatetime=300
set signcolumn=yes
" Use Tab to confirm completion.
inoremap <silent><expr> <TAB> pumvisible() ? coc#pum#confirm() : "\<TAB>"
" Ctrl-N and Ctrl-P will now use Vim's default behavior.
" Keep Enter for confirmation as well, as it's standard.
inoremap <silent><expr> <CR> pumvisible() ? coc#pum#confirm() : "\<C-g>u\<CR>"
let g:coc_snippet_next = '<tab>'
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" 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 <SID>ShowDocumentation()<CR>
function! s:ShowDocumentation()
if (coc#float#has_scroll())
call coc#float#scroll(1)
else
call feedkeys('K', 'in')
endif
endfunction
autocmd CursorHold * silent call CocActionAsync('highlight')
autocmd FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv']
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" airline {{{
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 = '◀'
let g:airline_right_alt_sep = '❮'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_theme = 'solarized'
" leaderf
let g:Lf_HideHelp = 1
let g:Lf_UseCache = 0
let g:Lf_UseVersionControlTool = 0
let g:Lf_IgnoreCurrentBufferName = 1
let g:Lf_ShowDevIcons = 1
let g:Lf_DevIconsFont = "Cascadia Code PL"
let g:Lf_WindowPosition = 'popup'
let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "Cascadia Code" }
let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }
let g:Lf_ShortcutF = "<leader>ff"
" 在普通模式下,使用<C-F>搜索光标下的单词(不立即执行)
nnoremap <silent> <C-F> :execute 'Leaderf rg --input='.expand('<cword>')<CR>
" 在可视模式下,使用<C-F>搜索选中的文本(不立即执行)
vnoremap <silent> <C-F> :<C-U>Leaderf rg --visual<CR>
" 在普通模式下,使用<C-B>在当前缓冲区搜索光标下的单词(不立即执行)
nnoremap <silent> <C-B> :execute 'Leaderf rg --current-buffer --input='.expand('<cword>')<CR>
" ctrlp ctrlpfunky{{{
" " let g:ctrlp_map = '<leader>p'
" " let g:ctrlp_cmd = 'CtrlP'
" " map <leader>f :CtrlPMRU<CR>
" " let g:ctrlp_custom_ignore = {
" " \ 'dir': '\v[\/]\.(git|hg|svn|rvm)$',
" " \ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz|pyc)$',
" " \ }
" " let g:ctrlp_working_path_mode=0
" " let g:ctrlp_match_window_bottom=1
" " let g:ctrlp_max_height=15
" " let g:ctrlp_match_window_reversed=0
" " let g:ctrlp_mruf_max=500
" " let g:ctrlp_follow_symlinks=1
" multiple-cursors
function! Multiple_cursors_before()
if exists(':NeoCompleteLock') == 2
execute 'NeoCompleteLock'
endif
endfunction
function! Multiple_cursors_after()
if exists(':NeoCompleteUnlock') == 2
execute 'NeoCompleteUnlock'
endif
endfunction
" python
let g:python_highlight_all = 1
" javascript {{{
" " pangloss/vim-javascript
" " let g:html_indent_inctags = "html,body,head,tbody"
" " let g:html_indent_script1 = "inc"
" " let g:html_indent_style1 = "inc"
" " javascript-libraries-syntax
" " let g:used_javascript_libs = 'jquery,react,flux'
" }}}
" neomake
" call neomake#configure#automake('nrwi', 500)
" let g:neomake_open_list = 2
" let g:neomake_python_enabled_makers = ['flake8']
" hive
autocmd BufNewFile,BufRead *.hql set filetype=hive expandtab
autocmd BufNewFile,BufRead *.q set filetype=hive expandtab
" ==========================================
" General Settings 基础设置
" ==========================================
let g:mapleader = ','
syntax on
filetype on
filetype indent on
filetype plugin on
filetype plugin indent on
set autoread
set wildignore=*.swp,*.bak,*.pyc,*.class,.svn
set cursorcolumn
set cursorline
" set t_ti= t_te=
set title
set viminfo^=%
set magic
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" ==========================================
" Display Settings Display/Layout and Interface Formatting Settings
" ==========================================
set lines=180 columns=210
set ruler
set showcmd
set showmode
set scrolloff=7
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?,\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
set laststatus=2
set statusline+=%F
set number
set nowrap
set showmatch
set matchtime=2
" Set smart search hints within text
set hlsearch
set incsearch
set ignorecase
set smartcase
" Code folding
set foldenable
set foldmethod=indent
set foldlevel=99
let g:FoldMethod = 0
nmap <leader>zz :call ToggleFold()<CR>
function! ToggleFold()
if g:FoldMethod == 0
execute "normal! zM"
let g:FoldMethod = 1
else
execute "normal! zR"
let g:FoldMethod = 0
endif
endfunction
" Indentation configuration
set smartindent
set autoindent
" Tab related changes
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab
set expandtab
set shiftround
set hidden
set wildmode=list:longest
set ttyfast
set nrformats=
set relativenumber number
autocmd FocusLost * set norelativenumber number
autocmd FocusGained * set relativenumber
autocmd InsertEnter * set norelativenumber number
autocmd InsertLeave * set relativenumber
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber number
else
set relativenumber
endif
endfunction
" nnoremap <C-n> :call NumberToggle()<CR>
" ==========================================
" FileEncode Settings File Encoding, Format
" ==========================================
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set helplang=cn
" set langmenu=zh_CN.UTF-8
" set enc=2byte-gb18030
set termencoding=utf-8
set ffs=unix,dos,mac
set formatoptions+=m
set formatoptions+=B
" ==========================================
" Others Other Settings
" ==========================================
autocmd! bufwritepost .vimrc source %
set completeopt=longest,menu
set wildmenu
set wildignore=*.o,*~,*.pyc,*.class
autocmd InsertLeave * if pumvisible() == 0 | pclose | endif
autocmd CmdwinEnter * nnoremap <buffer> <CR> <CR>
if has("autocmd")
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g'\"" | endif
endif
" ==========================================
" HotKey Settings Custom Hotkey Settings
" ==========================================
" F1 - F6 Settings
noremap <F1> <Esc>"
function! HideNumber()
if(&relativenumber == &number)
set relativenumber! number!
elseif(&number)
set number!
else
set relativenumber!
endif
set number?
endfunction
nnoremap <F3> :call HideNumber()<CR>
nnoremap <F4> :execute exists('syntax_on') ? 'syn off' : 'syn on'<CR>
nnorem <F5> :set list! list?<CR>
nnorem <F6> :set wrap! wrap?<CR>
noremap <silent><leader>/ :nohls<CR>
noremap # *
noremap * #
autocmd FileType python inoremap # X<c-h>#
" Tab operations
map <leader>th :tabfirst<CR>
map <leader>tl :tablast<CR>
map <leader>tj :tabnext<CR>
map <leader>tk :tabprev<CR>
map <leader>tn :tabnext<CR>
map <leader>tp :tabprev<CR>
map <leader>te :tabedit<CR>
map <leader>td :tabclose<CR>
map <leader>tm :tabm<CR>
" Switch to specific tab in normal mode
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<CR>
let g:last_active_tab = 1
nnorem <silent> <leader>tt :execute 'tabnext ' . g:last_active_tab<CR>
autocmd TabLeave * let g:last_active_tab = tabpagenr()
nnorem <C-t> :tabnew<CR>
inorem <C-t> <Esc>:tabnew<CR>
" ==========================================
" FileType Settings File Type Settings
" ==========================================
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType ruby,javascript,html,css,xml set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd BufRead,BufNewFile *.md,*.mkd,*.markdown set filetype=markdown.mkd
autocmd BufRead,BufNewFile *.part set filetype=html
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
autocmd BufWinEnter *.php set mps-=<:>
function! s:StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
execute '%s/\s\+$//e'
call cursor(l, c)
endfunction
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre <buffer> call <SID>StripTrailingWhitespaces()
function! s:AutoSetFileHead()
if &filetype == 'sh'
call setline(1, "#!/bin/bash")
endif
if &filetype == 'python'
call setline(1, "#!/usr/bin/env python")
call append(1, "# encoding: utf-8")
endif
normal G
normal o
normal o
endfunction
autocmd BufNewFile *.sh,*.py call <SID>AutoSetFileHead()
if has("autocmd")
if v:version > 701
autocmd Syntax * call matchadd('Todo', '\W\zs\(TODO\|FIXME\|CHANGED\|DONE\|XXX\|BUG\|HACK\)')
autocmd Syntax * call matchadd('Debug', '\W\zs\(NOTE\|INFO\|IDEA\|NOTICE\)')
endif
endif
" ==========================================
" Theme Settings Theme Settings
" ==========================================
if has("gui_running")
set guifont=Cascadia\ Code\ PL:h14
" set guifont=Monaco:h14
if has("gui_gtk2") " GTK2
set guifont=Monaco\ 14
endif
set guioptions-=T
set guioptions+=e
set guioptions-=r
set guioptions-=L
set guioptions-=m
set guitablabel=%M\ %t
set showtabline=1
set linespace=4
set noimd
set t_Co=256
endif
colorscheme solarized
let g:rehash256 = 1
set t_Co=256
set term=screen-256color
" floaterm
let g:floaterm_shell = 'zsh'
" hi Floaterm guibg=gray
nnorem <F10> <Cmd>FloatermToggle<CR>
" Transparent background
" hi Normal guibg=none ctermbg=none
nnorem <F7> :set background=light<CR>
nnorem <F8> :set background=dark<CR>
" Set sign column background color to match line number color
hi! link SignColumn LineNr
hi! link ShowMarksHLl DiffAdd
hi! link ShowMarksHLu DiffChange
" For error highlight, prevent entire line from being red and unreadable
highlight clear SpellBad
highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
highlight clear SpellCap
highlight SpellCap term=underline cterm=underline
highlight clear SpellRare
highlight SpellRare term=underline cterm=underline
highlight clear SpellLocal
highlight SpellLocal term=underline cterm=underline