-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
226 lines (183 loc) · 5.71 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
set t_ut=
set undodir=~/.vim/undo-dir
set undofile
" set nocompatible
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set encoding=utf8
"设置backspace 允许自动缩进, 允许换行符和连接线上退格, "开始插入的时候允许回退"
set backspace=start,indent,eol
"代码补全
"filetype plugin indent on
set completeopt=menu,popup,noselect
set pumheight=15
set scrolloff=3 "光标移动到buffer的底部和顶部时保留四行的距离
set history=1000 "设置命令历史上限
set fileencodings=utf-8,gbk,unicode
"set autochdir
"状态栏设置
"set laststatus=2
"set statusline=%t\ %y\ format:\ %{&ff};\ [%c,%l]
"显示命令
set showcmd
set nu
set rnu "设置相对行号
"执行查找前预览第一处匹配
set incsearch
set hlsearch
"设置normal模式下, BackSpace关闭高亮
nmap <BackSpace> :nohl<CR>
"设置命令行补全菜单
set wildmenu
"高亮当前行
set cursorline
"高亮当前列
set cursorcolumn
"windows 下自动缩进
set cindent
"按照C/C++风格自动缩进
syntax on
"启用鼠标支持
set mouse=a
" 设置垂直分割窗口时,分割到下方
set splitbelow
" colorscheme molokai
colorscheme one
set background=dark
" 设置命令行补全模式
set wildmode=longest,list,full
" 设置文件浏览器宽度
let g:netrw_winsize = 20
let g:netrw_altv = 1
let g:netrw_liststyle = 3
set guifont=Menlo-Regular:h16
"=================vim函数========================================
command Term :ter ++rows=8
"====================VIM运行设置====================
nnoremap gp `[v`]
"=====================debug======================================
func! Debug(bin_path)
exec "packadd termdebug"
exec "let g:termdebug_wide = 163"
exec "Termdebug "a:bin_path
endfunc
command -nargs=1 -complete=file Debug call Debug(<f-args>)
"设置vim中make命令
if filereadable("makefile")
set makeprg=make "默认使用make命令
elseif filereadable("WORKSPACE")
set makeprg=bazel\ build\ ...
endif
" wsl中使用,可以将vim中内容复制到windows的剪贴板
"map <F3> : call CopyAllToWindows()<CR>
"map! <F3> <ESC> : call CopyAllToWindows()<CR>
"vmap <F3> : write !/mnt/c/Windows/System32/clip.exe <CR>
"
"func! CopyAllToWindows()
" exec "w"
" exec "!cat % |/mnt/c/Windows/System32/clip.exe"
"endfunc
"========================编译运行end=====================================
"------------Plug config--------------------
call plug#begin('~/.vim/bundle')
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
Plug 'octol/vim-cpp-enhanced-highlight' ", { 'for' : ['c', 'cpp', 'vim', 'hpp', 'h'] }
"Plug 'majutsushi/tagbar'
Plug 'mileszs/ack.vim'
Plug 'alepez/vim-gtest'
"Plug 'SirVer/ultisnips'
"Plug 'honza/vim-snippets'
"Plug 'vim-airline/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
"Plug 'skywind3000/asynctasks.vim'
"Plug 'skywind3000/asyncrun.vim'
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
Plug 'puremourning/vimspector'
Plug 'junegunn/vim-easy-align'
"Plug 'lakshayg/vim-bazel'
call plug#end()
"filetype plugin indent on
"============插件的配置文件====================================
source ~/.vim/vimrcs/ack.vim
if filereadable(expand("$HOME/.vim/bundle/coc.nvim/plugin/coc.vim"))
source ~/.vim/vimrcs/coc.vim
endif
"source ~/.vim/vimrcs/airline.vim
source ~/.vim/vimrcs/leaderf.vim
"source ~/.vim/vimrcs/asynctasks.vim
"source ~/.vim/vimrcs/asyncrun.vim
"source ~/.vim/vimrcs/Tagbar.vim
source ~/.vim/vimrcs/easy_align.vim
"==============================================
set regexpengine=1
"加载当前工作目录下的vimrc文件
if filereadable("workspace.vim")
source workspace.vim
endif
"按语意折叠
set foldmethod=syntax
"设置打开默认不折叠
set foldlevelstart=99
" Set a nicer foldtext function
set foldtext=MyFoldText()
function! MyFoldText()
let line = getline(v:foldstart)
if match( line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$' ) == 0
let initial = substitute( line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '' )
let linenum = v:foldstart + 1
while linenum < v:foldend
let line = getline( linenum )
let comment_content = substitute( line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g' )
if comment_content != ''
break
endif
let linenum = linenum + 1
endwhile
let sub = initial . ' ' . comment_content
else
let sub = line
let startbrace = substitute( line, '^.*{[ \t]*$', '{', 'g')
if startbrace == '{'
let line = getline(v:foldend)
let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g')
if endbrace == '}'
let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', '...}\1', 'g')
endif
endif
endif
let n = v:foldend - v:foldstart + 1
let info = " " . n . " lines"
let sub = sub . " "
let num_w = getwinvar( 0, '&number' ) * getwinvar( 0, '&numberwidth' )
let fold_w = getwinvar( 0, '&foldcolumn' )
let sub = strpart( sub, 0, winwidth(0) - strlen( info ) - num_w - fold_w - 1 )
return sub . info
endfunction
" 设置全彩色支持
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
function Copy()
let c = join(v:event.regcontents,"\n")
let c64 = system("base64", c)
let s = "\e]52;c;" . trim(c64) . "\x07"
call s:raw_echo(s)
endfunction
function! s:raw_echo(str)
if has('win32') && has('nvim')
call chansend(v:stderr, a:str)
else
if filewritable('/dev/fd/2')
call writefile([a:str], '/dev/fd/2', 'b')
else
exec("silent! !echo " . shellescape(a:str))
redraw!
endif
endif
endfunction
autocmd TextYankPost * call Copy()