Repository navigation
Expand file tree
/
Copy pathinit.vim
More file actions
250 lines (206 loc) · 7.65 KB
/
Copy pathinit.vim
File metadata and controls
250 lines (206 loc) · 7.65 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
let mapleader=","
set termencoding=utf-8 "编码设置
set encoding=utf-8
set cursorline "高亮当前行
set hlsearch "高亮搜索
set incsearch "方便搜索
set wildmenu "命令补全
set wildmode=list:full
set autoindent "自动对齐
set smartindent "智能对齐
set tabstop=2
set softtabstop=2
set backspace=2
set shiftwidth=2
set mouse=a "启用鼠标
set foldenable "可折叠
set showmatch "匹配括号
set nowrap "不折行
set linebreak
set nobackup
set nowritebackup
set updatetime=300
set signcolumn=yes
set ignorecase "忽略大小写
set autochdir "自动切换工作目录
set visualbell "出错提示
set history=1000 "历史记录条数
set autoread "自动读取文件编辑
set nu "显示行号
set list "显示不可见字符
set listchars=tab:<->,trail:␣,extends:…
" 自动安装dein
let $CACHE = expand('~/.cache')
if !isdirectory($CACHE)
call mkdir($CACHE, 'p')
endif
if &runtimepath !~# '/dein.vim'
let s:dein_dir = fnamemodify('dein.vim', ':p')
if !isdirectory(s:dein_dir)
let s:dein_dir = $CACHE . '/dein/repos/github.com/Shougo/dein.vim'
if !isdirectory(s:dein_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_dir
endif
endif
execute 'set runtimepath^=' . substitute(
\ fnamemodify(s:dein_dir, ':p') , '[/\\]$', '', '')
endif
" 移除老旧兼容
set nocompatible
" 设置dein基础目录
let s:dein_base = '~/.cache/dein/'
" 设置dein所在路径
let s:dein_src = '~/.cache/dein/repos/github.com/Shougo/dein.vim'
" 设置运行时路径
execute 'set runtimepath+=' . s:dein_src
" 定义插件
call dein#begin(s:dein_base)
call dein#add(s:dein_src)
call dein#add('wsdjeg/dein-ui.vim')
call dein#add('neoclide/coc.nvim', { 'merged': 0, 'rev': 'release' }) "Coc补全
call dein#add('voldikss/vim-translator') " 翻译器
call dein#add('vim-airline/vim-airline') " 状态栏增强
call dein#add('vim-airline/vim-airline-themes')
call dein#add('cocopon/iceberg.vim') " Vim主题
call dein#add('ryanoasis/vim-devicons') " nerdtree文件美化
call dein#add('preservim/nerdtree') " 文件树形目录
call dein#add('Xuyuanp/nerdtree-git-plugin') " 文件树形目录git插件
call dein#add('preservim/tagbar') " 类预览
call dein#end()
" 探测代码类型
if has('filetype')
filetype indent plugin on
endif
" 代码高亮
if has('syntax')
syntax on
endif
" 自动安装
if dein#check_install()
call dein#install()
endif
colorscheme iceberg
set background=dark
set termguicolors
" 翻译器
" 在命令行中显示翻译结果
nmap <silent> <Leader>t <Plug>Translate
vmap <silent> <Leader>t <Plug>TranslateV
" 在弹窗中显示翻译结果
nmap <silent> <Leader>w <Plug>TranslateW
vmap <silent> <Leader>w <Plug>TranslateWV
" 将选中内容用翻译文本替换
nmap <silent> <Leader>r <Plug>TranslateR
vmap <silent> <Leader>r <Plug>TranslateRV
" 选中内容翻译并复制到剪切板
nmap <silent> <Leader>x <Plug>TranslateX
" 翻译弹窗可滚动
nnoremap <silent><expr> <M-f> translator#window#float#has_scroll() ?
\ translator#window#float#scroll(1) : "\<M-f>"
nnoremap <silent><expr> <M-b> translator#window#float#has_scroll() ?
\ translator#window#float#scroll(0) : "\<M-f>"
" 美化状态栏
set laststatus=2
let g:airline_powerline_fonts = 1
"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_left_sep = ' '
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='iceberg' " 使用主题
" 文件树
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
let NERDTreeShowHidden = 1
let NERDChristmasTree = 1
" Coc配置
call coc#add_extension('coc-snippets', 'coc-pyright', 'coc-prettier', 'coc-marketplace')
command! -nargs=0 Prettier :CocCommand prettier.formatFile
noremap <C-F> :Prettier<CR>
set updatetime=300
set signcolumn=yes
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>"
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <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)
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
autocmd CursorHold * silent call CocActionAsync('highlight')
nmap <leader>rn <Plug>(coc-rename)
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>ac <Plug>(coc-codeaction-cursor)
nmap <leader>as <Plug>(coc-codeaction-source)
nmap <leader>qf <Plug>(coc-fix-current)
nmap <silent> <leader>re <Plug>(coc-codeaction-refactor)
xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
nmap <leader>cl <Plug>(coc-codelens-action)
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)
" 使用 <C-f> <C-b> 滚动悬浮窗
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
command! -nargs=0 Format :call CocActionAsync('format')
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>