Open Tooooommy opened 3 years ago
" ======================================= " ===============插件管理================ " ======================================= " " Specify a directory for plugins " - For Neovim: stdpath('data') . '/plugged' " - Avoid using standard Vim directory names like 'plugin' call plug#begin('~/.vim/plugged') " Make sure you use single quotes Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'morhetz/gruvbox' Plug 'mhinz/vim-startify' Plug 'tpope/vim-fugitive' if has('nvim') || has('patch-8.0.902') Plug 'mhinz/vim-signify' else Plug 'mhinz/vim-signify', { 'branch': 'legacy' } endif Plug 'luochen1990/rainbow' Plug 'skywind3000/asyncrun.vim' Plug 'mg979/vim-visual-multi', {'branch': 'master'} Plug 'tpope/vim-repeat' Plug 'tpope/vim-surround' Plug 'tpope/vim-commentary' Plug 'tpope/vim-sensible' Plug 'tpope/vim-markdown' Plug 'haya14busa/incsearch.vim' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'mbbill/undotree' " Initialize plugin system call plug#end() "================================ "==============配置============== "================================ " " 设置leader键" let mapleader=' ' " vim 按键 set nocompatible " gui 字体 if has("gui_running") set guifont=SourceCodePro-Medium:h14 set guioptions-=m set guioptions-=T source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim endif " 默认更新时间 set updatetime=100 " fold " set foldmethod=indent " tab 空格 set tabstop=4 set softtabstop=4 set shiftwidth=4 set noexpandtab " expandtab " 设置剪贴板 set clipboard=unnamed " 带有如下符号的单词不要被换行分割 set iskeyword+=_,$,@,%,#,- " 高亮第 80 列,推荐 set colorcolumn=80 "设置水平/和竖直突出显示 set cursorline " 显示窗口比较小的时候折行展示,不然需要水平翻页,推荐 set linebreak " 设置行号 set number set relativenumber "编码设置 set encoding=utf-8 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 set fileformats=unix,dos,mac set termencoding=utf-8 set formatoptions+=m set formatoptions+= " 设置语言 set langmenu=zh_CN.UTF-8 set helplang=cn " 设置回到vim再上次的位置 au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif " =================================== " ============== 移动光标============ " =================================== " J K 快速移动上下五行 noremap <silent> K 5k noremap <silent> J 5j " 快速到行首 noremap H 0 " 快速到行尾 noremap L $ " 快速的单词跳转 noremap W 5w noremap B 5b " 查找和替换 noremap \s :%s//g<left><left> " 查找到的内容居中 nnoremap Y y$ " 插入模式下kj返回normal模式 inoremap jk <Esc> "=============================== "=========== coc.nvim ========== "=============================== " coc-marketplace/coc-go/coc-rust/coc-explorer " coc-sh/coc-xml/coc-json/coc-yaml/coc-yank/coc-pyright " coc-pairs/coc-lists/coc-lua/coc-clangd " coc-cmake/coc-snippets " TAB 补全 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 " ENTER 补全第一个 inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" " 错误诊断跳转 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) " <C-u> 删除之前的文本 " 调用CocList noremap <silent><nowait> <leader>ll :<C-u>CocList<CR> noremap <silent><nowait> <leader>ld :<C-u>CocList diagnostics<CR> noremap <silent><nowait> <leader>le :<C-u>CocList extensions<CR> noremap <silent><nowait> <leader>lc :<C-u>CocList commands<CR> noremap <silent><nowait> <leader>lo :<C-u>CocList outline<CR> noremap <silent><nowait> <leader>ls :<C-u>CocList -I symbols<CR> noremap <silent><nowait> <leader>lp :<C-u>CocListResume<CR> noremap <silent><nowait> <leader>lm :<C-u>CocList marketplace<CR> noremap <silent><nowait> <leader>ln :<C-u>CocList snippets<CR> " yank: coc-yank noremap <silent><nowait> <leader>ly :<C-u>CocList -A --normal yank<cr> " buffers noremap <silent><nowait> <leader>bb :<C-u>CocList buffers<CR> noremap <silent><nowait> <leader>bn :<C-u>bn<CR> noremap <silent><nowait> <leader>bp :<C-u>bp<CR> noremap <silent><nowait> <leader>bd :<C-u>bd<CR> noremap <silent><nowait> <leader>bd :<C-u>bd<CR> " theme noremap <silent><nowait> <leader>tt :<C-u>CocList colors<CR> " files noremap <silent><nowait> <leader>ff :<C-u>CocList files<CR> noremap <silent><nowait> <leader>ft :<C-u>CocCommand explorer<CR> noremap <silent><nowait> <leader>fs :<C-u>w<CR> noremap <silent><nowait> <leader>fg :<C-u>TagbarToggle<CR> noremap <silent><nowait> <leader>fr :<C-u>Ranger<CR> noremap <silent><nowait> <leader>fd :<C-u>x<CR> " git noremap <silent><nowait> <leader>gg :<C-u>Gstatus<CR> noremap <silent><nowait> <leader>gf :<C-u>Git fetch<CR> noremap <silent><nowait> <leader>gs :<C-u>Git stash<CR> noremap <silent><nowait> <leader>gb :<C-u>Git blame<CR> noremap <silent><nowait> <leader>gs :<C-u>Git status<CR> noremap <silent><nowait> <leader>gl :<C-u>Git log<CR> noremap <silent><nowait> <leader>gi :<C-u>Git init<CR> noremap <silent><nowait> <leader>gv :<C-u>GV<CR> "" help noremap <silent><nowait> <leader>hh :<C-u>CocList helptags<CR> noremap <silent><nowait> <leader>hk :<C-u>CocList maps<CR> "" windows noremap <silent><nowait> <leader>ww :<C-u>CocList windows<CR> noremap <silent><nowait> <leader>ws :<C-u>split<CR> noremap <silent><nowait> <leader>wv :<C-u>vsplit<CR> noremap <silent><nowait> <leader>wd :<C-u>q<CR> noremap <silent><nowait> <leader>w1 :<C-u>only<CR> noremap <silent><nowait> <leader>wo <C-w>w<CR> noremap <silent><nowait> <leader>wh <C-w>h<CR> noremap <silent><nowait> <leader>wj <C-w>j<CR> noremap <silent><nowait> <leader>wk <C-w>k<CR> noremap <silent><nowait> <leader>wl <C-w>l<CR> noremap <silent><nowait> <leader>w= <C-w>=<CR> noremap <silent><nowait> <leader>w<up>:<C-u>res +5<CR> noremap <silent><nowait> <leader>w<down> :<C-u>res -5<CR> noremap <silent><nowait> <leader>w<left> :<C-u>vertical resize -5<CR> noremap <silent><nowait> <leader>w<right> :<C-u>veritcal resize +5<CR> " search noremap <silent><nowait> <leader>ss :<C-u>CocList words<CR> noremap <silent><nowait> <leader>sa :<C-u>CocList grep<CR> noremap <silent><nowait> <leader>sn :<C-u><nohlsearch<CR> " isearch map / <Plug>(incsearch-forward) map ? <Plug>(incsearch-backward) map g/ <Plug>(incsearch-stay) map n <Plug>(incsearch-nohl-n) map N <Plug>(incsearch-nohl-N) map * <Plug>(incsearch-nohl-*) map # <Plug>(incsearch-nohl-#) map g* <Plug>(incsearch-nohl-g*) map g# <Plug>(incsearch-nohl-g#) " misc rename: 重命名 nnoremap <silent><nowait> <leader>rn <Plug>(coc-rename) nnoremap <silent><nowait> <leader>ut :UndotreeToggle<CR> """"go""""" " go tags autocmd FileType go noremap mta :<C-u>GoAddTags json<CR> autocmd FileType go noremap mty :<C-u>GoAddTags yaml<CR> autocmd FileType go noremap mtx :<C-u>GoAddTags xml<CR> autocmd FileType go noremap mtd :<C-u>GoRemoveTags<CR> " run & build autocmd FileType go noremap mxx :<C-u>GoRun .<CR> autocmd FileType go noremap mxb :<C-u>GoBuild .<CR> " go debug autocmd FileType go noremap mdd :<C-u>GoDebugBreakpoint<CR> autocmd FileType go noremap mds :<C-u>GoDebugStart<CR> autocmd FileType go noremap mdc :<C-u>GoDebugContinue<CR> autocmd FileType go noremap mdk :<C-u>GoDebugStop<CR> " check autocmd FileType go noremap mee :<C-u>GoMetaLinter<CR> autocmd FileType go noremap mev :<C-u>GoVet<CR> autocmd FileType go noremap mel :<C-u>GoLint<CR> autocmd FileType go noremap mec :<C-u>GoErrCheck<CR> " impl autocmd FileType go noremap mii :<C-u>GoImpl<CR> autocmd FileType go noremap mim :<C-u>GoImplements<CR> autocmd FileType go noremap mir :<C-u>GoReferres<CR> "================================ "===========coc-pairs============ "================================ autocmd FileType tex let b:coc_pairs = [["$", "$"]] "================================ "==========vim.go & coc-go======= "================================ let g:go_fmt_command = "goimports" let g:go_fmt_autosave = 1 "================================ "===========rainbow============== "================================ let g:rainbow_active = 1 "================================ "============theme============= "================================ colorscheme gruvbox set background=dark "=============================== "========vim-commentary========= "=============================== "为python和shell等添加注释 autocmd FileType python,shell set commentstring=#\ %s "修改注释风格 autocmd FileType c,cpp,go,rust set commentstring=//\ %s "============================== "========incsearch.vim========= "============================== let g:incsearch#auto_nohlsearch = 1 "============================= "========asyncrun.vim========= "============================= let g:asyncrun_open = 8