-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
executable file
·372 lines (305 loc) · 9.45 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
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
" c w 删除一个单词并进入写入模式
" c i " 删除双引号之间的文本 并进入写入模式
" d i " 删除双引号之间的文本 不进入写入模式
" f w 寻找最近的w
" c f " 改变当前位置到w之间的内容
" d f " 删除当前位置到w之间的内容
" this vim editor: hello world
set number "显示行号
"set nonu "取消显示行号
"
set relativenumber "相对行号
"set norelativenumber "取消相对行号
set wrap "显示不会出当前界面
set showcmd "显示cmd
set ruler
set nocompatible "关闭vi的兼容模式
set cursorline "显示线条
set wildmenu "vim自身命令行模式智能补全
set mouse=a "可以使用鼠标
"set scrolloff=5 "保证光标下面永远显示5行
set hlsearch "设置搜索高亮
"第一次进入关闭高亮
exec "nohlsearch"
set incsearch "开启实时搜索
set ignorecase "忽略大小写
set smartcase "智能大小写
"set list "显示行尾空格
filetype on " 开启文件类型侦测
filetype plugin on " 根据侦测到的不同类型加载对应的插件
filetype indent on "自适应不同语言的智能缩进
filetype plugin indent on "自适应不同语言的智能缩进
set encoding=utf-8
"set ignorecase "搜索时大小写不敏感
"syntax enable "开启语法高亮功能
"syntax on "允许使用指定语法高亮配色方案代替默认方案
" 禁用backspace/delete按键
" more powerful backspacing
" set backspace=indent,eol,start
set backspace=2
" nnoremap <backspace> <nop>
" inoremap <backspace> <nop>
set expandtab "将制表符扩展为空格
set tabstop=4 "设置编辑时制表符所占空格数
set shiftwidth=4 "设置格式化时制表符所占空格数
set softtabstop=4 "让vim吧连续数量的空格视为一个制表符
set foldmethod=indent "代码块收起
set foldlevel=99
" 改变光标在不同模式下的显示
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
set laststatus=2
set autochdir
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif "再次打开文件时光标默认回到上次的位置
let g:mapleader=" "
noremap <LEADER><CR> :nohlsearch<CR> "取消搜索高亮显示
noremap n nzz "搜索下一条到中心
noremap N Nzz "搜索下一条到中心
let g:indentLine_setColors = 0
let g:indentLine_color_term = 239
let g:indentLine_char = '|'
let g:indentLine_enabled = 1
let g:autopep8_disable_show_diff = 1
"取消s映射
map s <nop>
"大写S保存
map S :w<CR>
"大写Q退出
map Q :q<CR>
"大写Q退出
map <LEADER>Q :wa<CR>:q<CR>
"大写R重新加载.vimrc
map R :source $MYVIMRC<CR>
"大写Q退出
tnoremap Q <Esc><C-\><C-n>:q!<CR>
"大写Q退出
tnoremap <Esc> <C-\><C-n>
" 让配置变更立即生效
autocmd BufWritePost $MYVIMRC source $MYVIMRC
"自定义窗口分屏
map sl :set splitright<CR>:vsplit<CR> "分屏之后光标在右边
map sh :set nosplitright<CR>:vsplit<CR> "分屏之后光标在左边
map sk :set nosplitbelow<CR>:split<CR> “分屏之后光标在上面
map sj :set splitbelow<CR>:split<CR> "分屏之后光标在下面
" 自定义termainalmap分屏
" 打开一个新的终端
"分屏之后光标在下面
map st :set splitbelow<CR>:split<CR>:term<CR>A python3
"map st :term<CR>
" 自定义窗口切换快捷键
"光标向右移动
map <S-k> <C-w>k
tmap <S-k> <C-w>k
"光标向左移动
map <S-j> <C-w>j
tmap <S-j> <C-w>j
"光标向上移动
map <S-h> <C-w>h
tmap <S-h> <C-w>h
"光标向下移动
map <S-l> <C-w>l
tmap <S-l> <C-w>l
"自定义上下左右为改变分屏大小
map <up> :res -5<CR>
map <down> :res +5<CR>
map <left> :vertical resize-5<CR>
map <right> :vertical resize+5<CR>
"自定义标签页快捷键
map tt :tabe<CR>
map <LEADER>h :-tabnext<CR> "移动到上一个标签页
map <LEADER>l :+tabnext<CR> "移动到下一个标签页
" 按 F5 执行当前 Python 代码"
map <F5> :w<cr>:r!python3 %<cr>
" vim-plug
call plug#begin('~/.vim/plugged')
"安装插件
"Plug 'python-mode/python-mode', { 'branch': 'develop' }
"vim启动
Plug 'mhinz/vim-startify'
" material主题
Plug 'kaicataldo/material.vim', { 'branch': 'main' }
" markdown
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'iamcco/mathjax-support-for-mkdp'
Plug 'iamcco/markdown-preview.vim'
"vim aiarline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" vim-snazzy主题
Plug 'connorholyday/vim-snazzy'
Plug 'morhetz/gruvbox'
Plug 'tomasr/molokai'
Plug 'sindresorhus/iterm2-snazzy'
" nerdtree
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} "目录树
Plug 'Xuyuanp/nerdtree-git-plugin' "为nerdtree添加git支持
" cocvim
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" 代码错误提示
Plug 'w0rp/ale'
" surround
Plug 'tpope/vim-surround'
" easy motion
" Plug 'easymotion/vim-easymotion'
" 缩进
Plug 'Yggdroot/indentLine'
" jedi
Plug 'davidhalter/jedi-vim'
" format
Plug 'sbdchd/neoformat'
" comment code
Plug 'manasthakur/vim-commentor'
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
" coc-vim settins.location config
let g:coc_config_file="$HOME/.vim/.config/coc/settings.json"
" deoplete
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
" file search
" Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Plug 'junegunn/fzf.vim'
endif
let g:deoplete#enable_at_startup = 1
call plug#end()
"format
nnoremap ; :Neoformat! python yapf<CR>
let g:neoformat_python_autopep8 = {
\ 'exe': 'autopep8',
\ 'args': ['-s 4', '-E'],
\ 'replace': 1,
\ 'stdin': 1,
\ 'env': ["DEBUG=1"],
\ 'valid_exit_codes': [0, 23],
\ 'no_append': 1,
\ }
let g:neoformat_enabled_python = ['autopep8']
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
" ===
" === 主题设置
" ===
" colorscheme molokai
" colorscheme gruvbox
" colorscheme snazzy
colorscheme material
"let g:material_style='palenight'
" let g:molokai_original = 1
"let g:SnazzyTransparent = 1
let g:impact_transbg=1
let g:rehash256 = 1
let g:material_terminal_italics = 1
let g:material_theme_style = 'palenight'
set t_Co=256
set background=dark
" For Neovim 0.1.3 and 0.1.4 - https://github.com/neovim/neovim/pull/2198
if (has('nvim'))
let $NVIM_TUI_ENABLE_TRUE_COLOR = 1
endif
" For Neovim > 0.1.5 and Vim > patch 7.4.1799 - https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
" Based on Vim patch 7.4.1770 (`guicolors` option) - https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
" https://github.com/neovim/neovim/wiki/Following-HEAD#20160511
if (has('termguicolors'))
set termguicolors
endif
" ===
" === leaderF
" ===
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
" ===
" === comment code
" ===
" nmap // gcc
" ===
" === NERDTree
" ===
map <LEADER><LEADER> <:NERDTreeToggle<CR>
map <LEADER>v :NERDTreeFind<CR>
let NERDTreeMapOpenInTab = "o"
"let NERDTreeMapOpenExpl = ""
"let NERDTreeMapUpdir = ""
"let NERDTreeMapUpdirKeepOpen = "l"
"let NERDTreeMapOpenSplit = ""
"let NERDTreeOpenVSplit = ""
"let NERDTreeMapActivateNode = "i"
"let NERDTreeMapPreview = ""
"let NERDTreeMapCloseDir = "n"
"let NERDTreeMapChangeRoot = "y"
" === python-mode配置
" ===
" ===
" 默认删除空白符
"let g:pymode_python = "python3"
"" 删除空白符
"let g:pymode_trim_whitespaces = 1
""
"let g:pymode_doc=1
"let g:pymode_doc_bind = 'K'
"let g:pymode_rope_goto_definition_bind = "<C-]>"
"" let g:pymode_rope_goto_definition_bind = "<LEADER-o>"
"" 默认开启检查
"let g:pymode_lint = 1
"let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe', 'pylint']
"let g:pymode_options_max_line_length = 120
" ===
" === ale
" ===
let b:ale_linters = ['pylint']
let b:ale_fixers = ['autopep8', 'yapf']
" ===
" === Python-syntax
" ===
let g:python_highlight_all = 1
" let g:python_slow_sync = 0
" === airline配置
" ===
" ===
let g:airline_powerline_fonts = 1
"let g:airline_theme='deus'
let g:airline_theme='material'
let g:Powerline_symbols='fancy'
let Powerline_symbols='fancy'
set t_Co=256 " 状态栏就有颜色了" ...
" === easymotion配置
" ===
" ===
nmap ss <Plug>(easymotion-s2)
" === coc-nvim
" ===
" ===
let g:coc_global_extensions = ['coc-json', 'coc-python', 'coc-git', 'coc-vimlsp', 'coc-marketplace']
" Use tab for trigger completion with characters ahead and navigate.
" 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>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-o> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-o> coc#refresh()
else
inoremap <silent><expr> <c-o> coc#refresh()
endif
" 使用enter触发补全选中 并格式化
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
autocmd CursorHold * silent call CocActionAsync('highlight')
nmap <silent> <leader>- <Plug>(coc-diagnostic-prev)
nmap <silent> <leader>+ <Plug>(coc-diagnostic-next)
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)