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
| " 关闭兼容模式 set nocompatible
set nu! " 设置行号 set cursorline "突出显示当前行
" set cursorcolumn " 突出显示当前列 set showmatch " 显示括号匹配 set guioptions-=L " 隐藏左侧滚动条
" tab 缩进 set tabstop=4 " 设置Tab长度为4空格 set shiftwidth=4 " 设置自动缩进长度为4空格 set autoindent " 继承前一行的缩进方式,适用于多行注释 set smartindent " 开启新行时使用智能自动缩进
" 定义快捷键的前缀,即<Leader> let mapleader=";"
" 开启实时搜索 set incsearch
" 搜索时大小写不敏感 set ignorecase syntax enable syntax on " 开启文件类型侦测 filetype plugin indent on " 启用自动补全
" 窗口分割时,进行切换的按键热键需要连接两次,比如从下方窗口移动 " 光标到上方窗口,需要<c-w><c-w>k,非常麻烦,现在重映射为<c-k>,切换的 " 时候会变得非常方便. nnoremap <C-h> <C-w>h nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-l> <C-w>l
" 插件开始的位置 call plug#begin('~/.vim/plugged')
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align " 可以快速对齐的插件 Plug 'junegunn/vim-easy-align'
" 用来提供一个导航目录的侧边栏 Plug 'scrooloose/nerdtree'
" 可以使 nerdtree 的 tab 更加友好些 Plug 'jistr/vim-nerdtree-tabs'
" 可以在导航目录中看到 git 版本信息 Plug 'Xuyuanp/nerdtree-git-plugin'
" 查看当前代码文件中的变量和函数列表的插件, " 可以切换和跳转到代码中对应的变量和函数的位置 " 大纲式导航, Go 需要 https://github.com/jstemmer/gotags 支持 Plug 'majutsushi/tagbar'
" 自动补全括号的插件,包括小括号,中括号,以及花括号 Plug 'jiangmiao/auto-pairs'
" Vim状态栏插件,包括显示行号,列号,文件类型,文件名,以及Git状态 Plug 'vim-airline/vim-airline'
" 有道词典在线翻译 Plug 'ianva/vim-youdao-translater'
" 代码自动完成,安装完插件还需要额外配置才可以使用 Plug 'Valloric/YouCompleteMe'
" 可以在文档中显示 git 信息 Plug 'airblade/vim-gitgutter'
" 下面两个插件要配合使用,可以自动生成代码块 Plug 'SirVer/ultisnips' Plug 'honza/vim-snippets'
" 可以在 vim 中使用 tab 补全 Plug 'vim-scripts/SuperTab'
Plug 'Blackrush/vim-gocode'
" 可以在 vim 中自动完成 Plug 'Shougo/neocomplete.vim'
" go 主要插件 Plug 'fatih/vim-go', { 'tag': '*' } " go 中的代码追踪,输入 gd 就可以自动跳转 Plug 'dgryski/vim-godef'
" markdown 插件 Plug 'iamcco/mathjax-support-for-mkdp' Plug 'iamcco/markdown-preview.vim'
" 插件结束的位置,插件全部放在此行上面 call plug#end()
au InsertLeave *.go,*.rs,*.md,*.conf,*.yml,*.yaml,*.sh,*.php write
autocmd vimenter * NERDTree
"============================================================================== "vim-go 插件 "==============================================================================
let g:go_fmt_command = "goimports" " 格式化将默认的 gofmt 替换 let g:go_autodetect_gopath = 1 let g:go_list_type = "quickfix"
let g:go_version_warning = 1 let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_function_calls = 1 let g:go_highlight_operators = 1 let g:go_highlight_extra_types = 1 let g:go_highlight_methods = 1 let g:go_highlight_generate_tags = 1
let g:godef_split=2
"============================================================================== " go-def 插件 "==============================================================================
let g:godef_split=1 let g:godef_same_file_in_same_window=1
"============================================================================== " Gotags 插件 "==============================================================================
nmap <C-O> :TagbarToggle<CR> let g:tagbar_type_go = { \ 'ctagstype' : 'go', \ 'kinds' : [ \ 'p:package', \ 'i:imports:1', \ 'c:constants', \ 'v:variables', \ 't:types', \ 'n:interfaces', \ 'w:fields', \ 'e:embedded', \ 'm:methods', \ 'r:constructor', \ 'f:functions' \ ], \ 'sro' : '.', \ 'kind2scope' : { \ 't' : 'ctype', \ 'n' : 'ntype' \ }, \ 'scope2kind' : { \ 'ctype' : 't', \ 'ntype' : 'n' \ }, \ 'ctagsbin' : 'gotags', \ 'ctagsargs' : '-sort -silent' \ }
"============================================================================== " NERDTree 插件 "==============================================================================
" 打开和关闭NERDTree快捷键 map <F10> :NERDTreeToggle<CR> " 显示行号 let NERDTreeShowLineNumbers=1 " 打开文件时是否显示目录 let NERDTreeAutoCenter=1 " 是否显示隐藏文件 let NERDTreeShowHidden=0 " 设置宽度 let NERDTreeWinSize=31 " 忽略一下文件的显示 let NERDTreeIgnore=['\.pyc','\~$','\.swp'] " 打开 vim 文件及显示书签列表 let NERDTreeShowBookmarks=2 " 在终端启动vim时,共享NERDTree let g:nerdtree_tabs_open_on_console_startup=1
"============================================================================== " Valloric/YouCompleteMe 插件 "==============================================================================
" preview window settiing let g:ycm_add_preview_to_completeopt = 1 let g:ycm_autoclose_preview_window_after_completion = 0 let g:ycm_autoclose_preview_window_after_insertion = 1
" typing 2 chars let g:ycm_min_num_of_chars_for_completion = 2 " Completion when typing inside comments let g:ycm_complete_in_comments = 1 " Query the UltiSnips plugin let g:ycm_use_ultisnips_completer = 1 " Collect identifiers from strings and comments and tag fiels let g:ycm_collect_identifiers_from_comments_and_strings = 1 let g:ycm_collect_identifiers_from_tags_files = 1
" some symbols let g:ycm_error_symbol = '>>' let g:ycm_warning_symbol = '>*'
" Specifies Python interpreter to run jedi let g:ycm_python_binary_path = 'python3'
" " Seed its identifier database " let g:ycm_seed_identifiers_with_syntax=1
" youcompleteme select keys let g:ycm_key_list_select_completion = ['<C-J>'] let g:ycm_key_list_previous_completion = ['<C-K>']
" Where GoTo* commands result should be opened, same-buffer let g:ycm_goto_buffer_command = 'horizontal-split' " nnoremap <leader>jd :YcmCompleter GoToDefinition<CR> nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> nnoremap <leader>gd :YcmCompleter GoToDeclaration<CR>
"============================================================================== " 其他插件配置 "==============================================================================
" markdwon 的快捷键 map <silent> <F5> <Plug>MarkdownPreview map <silent> <F6> <Plug>StopMarkdownPreview
" tab 标签页切换快捷键 :nn <Leader>1 1gt :nn <Leader>2 2gt :nn <Leader>3 3gt :nn <Leader>4 4gt :nn <Leader>5 5gt :nn <Leader>6 6gt :nn <Leader>7 7gt :nn <Leader>8 8gt :nn <Leader>9 8gt :nn <Leader>0 :tablast<CR>
|