-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
252 lines (206 loc) · 7.92 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
"Vundle配置
"===============================================
set nocompatible " 这是必需的
filetype off " 这是必需的
" 在此设置运行时路径
set rtp+=~/.vim/bundle/Vundle.vim
" vundle初始化
call vundle#begin()
" 或者传递一个 Vundle 安装插件的路径
"call vundle#begin('~/some/path/here')
" 让 Vundle 管理 Vundle, 必须
Plugin 'VundleVim/Vundle.vim'
" 下面是不同支持幅度的例子
" 保持 Plugin 命令 在 vundle#begin 和 end 之间
" plugin 在 GitHub 仓库
Plugin 'tpope/vim-fugitive'
" 来自http://vim-scripts.org/vim/scripts.html的插件
" Plugin 'L9'
" 未托管在GitHub上的Git插件
" Plugin 'git://git.wincent.com/command-t.git'
" 本地机器上的git软件库(即编写自己的插件时)
" Plugin 'file:///home/gmarik/path/to/plugin'
" sparkup vim脚本在名为vim的该软件库子目录下。
" 传递路径,合理设置运行时路径。
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" 安装 L9 并避免名称冲突
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
"Plugin 'godlygeek/tabular'
Plugin 'ycm-core/YouCompleteMe'
Plugin 'iamcco/markdown-preview.nvim'
Plugin 'SirVer/ultisnips'
Plugin 'fatih/vim-go'
"Plugin 'OmniSharp/omnisharp-vim'
Plugin 'mattn/emmet-vim'
"Plugin 'Chiel92/vim-autoformat'
"每个插件都应该在这一行之前
call vundle#end() " 这是必需的
filetype plugin indent on " 这是必需的
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"
"===============================================================================
"markdown配置
"===============================================================================
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 1
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 1
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {}
\ }
" use a custom markdown style must be absolute path
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = '7777'
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"===============================================================================
"样式基本设置
"========================================================================
syntax on "代码高亮显示
filetype indent plugin on
set encoding=utf-8 "编码格式
let &termencoding=&encoding
set fileencodings=utf-8,gb18030,gbk,gb2312,big5
set number "显示行号
set cursorline "光标所在行
"美化所在行
" highlight CursorLine cterm=NONE ctermbg=darkcyan ctermfg=black guibg=NONE guifg=NONE
set nowrap "关闭自动折叠行
set modeline
set background=dark
set tabstop=8
set expandtab
set softtabstop=4
set shiftwidth=4
set showcmd "底部显示命令
set showmode "显示模式
set t_Co=256 "启用256色
set autoindent "自动缩进
set scrolloff=5 "滚动间距
set sidescrolloff=15 "水平滚动间距
set laststatus=2 "是否显示状态栏。0 表示不显示,1 表示只在多窗口时显示,2 表示显示
set ruler "在状态栏显示光标的当前位置(位于哪一行哪一列
set showmatch "光标遇到圆括号、方括号、大括号时,自动高亮对应的另一个圆括号、方括号和大括号
set hlsearch "搜索时,高亮显示匹配结果
set incsearch
set smartcase "搜索智能忽略大小写
"set spell spelllang=en_us "英语拼写检查
"set backupdir=~/.vim/.backup//
"set directory=~/.vim/.swp//
"set undodir=~/.vim/.undo//
set history=1000 "记住多少次历史
set autoread "打开自动监视
set wildmenu
set wildmode=longest:list,full "命令自动补全
set ignorecase smartcase
"set noswapfile
"不设置交换文件
"===================================
"ycm与键位配置
"========================================
let g:ycm_use_clangd = 0
let g:ycm_python_interpreter_path = '/usr/lib/python3.8'
let g:ycm_python_sys_path = ['/usr/lib/python3.8',]
let g:ycm_extra_conf_vim_data = [
\ 'g:ycm_python_interpreter_path',
\ 'g:ycm_python_sys_path'
\]
let g:ycm_global_ycm_extra_conf = '~/.vim/.global_extra_conf.py'
let g:ycm_filepath_blacklist = {
\ 'html': 1,
\ 'jsx': 1,
\ 'xml': 1,
\}
let mapleader=" "
noremap <LEADER> <nop>
noremap <LEADER>s :w!<CR>
noremap <LEADER>q :q!<CR>
noremap <LEADER>S :wq!<CR>
autocmd FileType html,css EmmetInstall
autocmd FileType go noremap <LEADER>f :GoFmt<CR>
"format go
autocmd FileType json noremap <LEADER>f :%!python -m json.tool<CR>
"format json
autocmd FileType html noremap <LEADER>f gg:%s/</\r</g<CR>gg:%s/>/>\r/g<CR>gg=G:g/^$/d<CR>
"format html
autocmd FileType go noremap <LEADER>c :norm 0i// <CR>
autocmd FileType go noremap <LEADER>C :norm 0f/diw<CR>
autocmd FileType java noremap <LEADER>c :norm 0i// <CR>
autocmd FileType java noremap <LEADER>C :norm 0f/diw<CR>
autocmd FileType python noremap <LEADER>c :norm 0i## <CR>
autocmd FileType python noremap <LEADER>C :norm 0f#diw<CR>
autocmd FileType sh noremap <LEADER>c :norm 0i## <CR>
autocmd FileType sh noremap <LEADER>C :norm 0f#diw<CR>
"注释与取消注释
autocmd FileType markdown noremap <LEADER>r :MarkdownPreview
autocmd FileType go noremap <buffer> <LEADER>r :!clear&go run %
autocmd FileType python noremap <buffer> <LEADER>r :!clear&python %
autocmd FileType java noremap <buffer> <LEADER>r :!clear&java %
autocmd FileType sh noremap <buffer> <LEADER>r :!clear&bash %
"文件运行
noremap <LEADER>/ :nohlsearch<CR>