forked from Mopip77/dotfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
264 lines (227 loc) · 7.6 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
call plug#begin('~/.vim/plugged')
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
Plug 'easymotion/vim-easymotion'
Plug 'scrooloose/nerdtree'
Plug 'mhinz/vim-startify'
Plug 'Yggdroot/indentLine'
Plug 'vim-scripts/indentpython.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'jnurmine/Zenburn'
Plug 'mileszs/ack.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
Plug 'junegunn/fzf.vim'
Plug 'tmhedberg/SimpylFold'
Plug 'nvie/vim-flake8'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'majutsushi/tagbar'
Plug 'Chiel92/vim-autoformat'
Plug 'sbdchd/neoformat'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'rking/ag.vim'
Plug 'junegunn/vim-easy-align'
Plug 'ryanoasis/vim-devicons'
Plug 'github/copilot.vim'
Plug 'neoclide/coc.nvim'
" theme
Plug 'w0ng/vim-hybrid'
Plug 'sjl/badwolf'
Plug 'jpo/vim-railscasts-theme'
Plug 'arcticicestudio/nord-vim'
Plug 'joshdick/onedark.vim'
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
Plug 'sainnhe/gruvbox-material'
call plug#end()
" leaderF
let g:Lf_ShortcutF = '<c-p>'
noremap <Leader>p :LeaderfFunction<cr>
" python
let g:python3_host_skip_check=1
let g:python3_host_prog='/usr/local/bin/python3'
" global
let mapleader=','
let python_highlight_all=1
set noshowmode
set ts=4
"set expandtab
set autoindent
set noundofile
set rnu
set nu
set mouse=a
set updatetime=100 " 更新时间, 目前用于gitgutter
set shiftwidth=4
" 设置不可见字符样式
set list
set listchars=tab:→\ ,nbsp:␣,trail:•,extends:⟩,precedes:⟨
"highlight LineNr cterm=bold ctermfg=white
"highlight pythonFunction cterm=bold ctermfg=blue
"highlight pythonString cterm=bold ctermfg=green
" 使用 jj 进入 normal 模式
inoremap jj <Esc>`^
" 使用 leader+q 直接退出
inoremap <leader>q <Esc>:q<cr>
noremap <leader>q :q<cr>
" 使用 leader+w 直接保存
inoremap <leader>w <Esc>:w<cr>
noremap <leader>w :w<cr>
" 使用cdc 进入当前文件的目录
cnoremap cdc cd %:h
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
" 使用tab键切换tab
nnoremap <tab> gt
nnoremap <S-tab> gT
set encoding=UTF-8
set cursorline
set nobackup
set noswapfile
syntax on
syntax enable
set background=dark
" https://github.com/w0ng/vim-hybrid
"let g:hybrid_custom_term_colors = 1
"let g:hybrid_reduced_contrast = 1 " Remove this line if using the default palette.
"colorscheme hybrid
colorscheme gruvbox-material
let g:gruvbox_material_background = 'soft'
let g:gruvbox_material_better_performance = 1
" 特定格式 文件下使用两个空格
filetype on
"autocmd BufNewFile,BufRead *.(sh|json|html|yaml) set noexpandtab tabstop=2 shiftwidth=2
autocmd Filetype html setl ts=2 sw=2 expandtab
autocmd Filetype sh setl ts=2 sw=2 expandtab
autocmd Filetype json setl ts=2 sw=2 expandtab
autocmd Filetype yaml setl ts=2 sw=2 expandtab
autocmd Filetype lua setl ts=2 sw=2 expandtab
" fast copy
:map <Leader>c "+y
" window move
nnoremap <C-j> <C-W><C-J>
nnoremap <C-k> <C-W><C-K>
nnoremap <C-l> <C-W><C-L>
nnoremap <C-h> <C-W><C-H>
" remember last postion
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" nerdtree
map <leader>n :NERDTreeToggle<CR>
map <leader>v :NERDTreeFind<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
let NERDTreeShowHidden=1
let NERDTreeIgnore=['\.pyc','\~$','\.swp','\.git']
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ "Unknown" : "?"
\ }
" NERDTress File highlighting
"function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
"exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
"exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
"endfunction
"call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
"call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
"call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
"call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
"call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
"call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
"call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
"call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
"call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
"call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
"call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
"call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
"call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
" lightline
"set laststatus=2
"let g:lightline = {
"\ 'colorscheme': 'wombat',
"\ }
" easymotion
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
map <Leader><Leader>f <Plug>(easymotion-overwin-f)
map <Leader><Leader>w <Plug>(easymotion-bd-w)
map <Leader><leader>h <Plug>(easymotion-linebackward)
map <Leader><Leader>j <Plug>(easymotion-j)
map <Leader><Leader>k <Plug>(easymotion-k)
map <Leader><leader>l <Plug>(easymotion-lineforward)
" 重复上一次操作, 类似repeat插件, 很强大
map <Leader><leader>. <Plug>(easymotion-repeat)
" ag
let g:ackprg = 'ag --vimgrep'
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" fzf
nnoremap <silent> <Leader>ag :Ag
nnoremap <silent> <Leader>f :Files<CR>
" neoformat
nnoremap <silent> <Leader>g :Neoformat<CR>
" folding
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
let g:SimpylFold_docstring_preview=1
" indentLine
" json文件展示双引号
let g:indentLine_setConceal = 0
" airline
let g:airline_theme="bubblegum"
let g:airline_powerline_fonts = 1
" vim-gitgutter
let g:gitgutter_max_signs = 500 " default value
highlight GitGutterAdd ctermfg=2
highlight GitGutterChange ctermfg=3
highlight GitGutterDelete ctermfg=1
" tagbar
" 打开tagbar后光标自动进入tagbar
let g:tagbar_autofocus = 1
nnoremap <Leader>t :TagbarToggle<CR>
" Neoformat
let g:formatter_yapf_style = 'pep8'
noremap <F3> :Neoformat<CR>:w<CR>
" EasyAlign
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" 当新建 .h .c .hpp .cpp .mk .sh等文件时自动调用SetTitle 函数
autocmd BufNewFile *.py exec ":call SetPyTitle()"
" 加入注释
func SetPyTitle()
call setline(1, "#-*- coding:utf-8 -*-")
call append(line("."), "\"\"\"")
call append(line(".")+1, "@file : ".expand("%:t"))
call append(line(".")+2, "@author: Mopip77")
call append(line(".")+3, "@mail : [email protected]")
call append(line(".")+4, "@time : ".strftime("%Y-%m-%d %H:%M:%S"))
call append(line(".")+5, "\"\"\"")
call append(line(".")+6, "")
normal G
endfunc
autocmd BufNewFile *.sh exec ":call SetShellTitle()"
" 加入注释
func SetShellTitle()
call setline(1, "#!/bin/bash")
call setline(2, "set -euo pipefail")
call setline(3, "IFS=$'\\n\\t'")
normal Go
endfunc