" auto install vim-plug let vim_plug_just_installed = 0 let vim_plug_path = expand('~/.vim/autoload/plug.vim') if !filereadable(vim_plug_path) echo "Installing Vim-plug..." echo "" silent !mkdir -p ~/.vim/autoload silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://gitee.com/klesh/vim-plug/raw/master/plug.vim let vim_plug_just_installed = 1 endif " manually load vim-plug the first time if vim_plug_just_installed :execute 'source '.fnameescape(vim_plug_path) endif if !has('nvim') "set mouse=a set ttymouse=xterm2 endif set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 let s:uname = system("uname -s") let s:nix = s:uname =~ '\(Darwin\|Linux\)\n' if s:nix call plug#begin() else set rtp+=$VIM/bundle/Vundle.vim/ " 把 Vundle 加入搜索路径 call plug#begin('$VIM/bundle/') language messages zh_CN.utf-8 set langmenu=zh_CN.utf-8 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set guioptions-=T source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim endif " searching and formatting Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '(GrepperOperator)'] } Plug 'ctrlpvim/ctrlp.vim' Plug 'godlygeek/tabular' " align text by specified pattern :Tabularize / Plug 'editorconfig/editorconfig-vim' Plug 'tpope/vim-surround' Plug 'tpope/vim-repeat' Plug 'alvan/vim-closetag' Plug 'jiangmiao/auto-pairs' " ide like Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} Plug 'weirongxu/coc-explorer', {'do': 'yarn install --frozen-lockfile'} Plug 'scrooloose/nerdcommenter' Plug 'tpope/vim-fugitive' " git 功能 "Plug 'scrooloose/nerdtree' "Plug 'mgedmin/coverage-highlight.vim' "Plug 'klesh/vim-fakeclip' " color themes Plug 'morhetz/gruvbox' " syntax Plug 'peitalin/vim-jsx-typescript' Plug 'pangloss/vim-javascript' Plug 'lunaru/vim-less' Plug 'posva/vim-vue' Plug 'othree/html5.vim' Plug 'dag/vim-fish' "Plug 'vim-python/python-syntax' Plug 'plasticboy/vim-markdown' "Plug 'digitaltoad/vim-pug' " statusline Plug 'liuchengxu/eleline.vim' call plug#end() " ==== coc configuration ==== nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) xmap fs (coc-format-selected) nmap fs (coc-format-selected) nmap fb (coc-format) nmap rn (coc-rename) nmap ne (coc-diagnostic-next-error) nmap pe (coc-diagnostic-prev-error) nmap fe :CocCommand explorer --toggle nmap if :CocInfo nmap cl :CocList nmap ol (coc-openlink) " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') " Use K to show documentation in preview window function! s:show_documentation() " s:f makes function f local, use f() to call it, ! replaces existing " function quitely if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction nnoremap K :call show_documentation() " ==== markdown configuration ==== let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_math = 1 " ==== nerdtree configuration ==== let NERDTreeDirArrowExpandable = "+" let NERDTreeDirArrowCollapsible = "-" let NERDTreeIgnore = ['\.pyc$', '__pycache__'] " ==== python configuration ==== let g:python_highlight_all = 1 " ==== ctrlp configuration ==== let g:ctrlp_user_command = ['.git', 'git ls-files -co --exclude-standard'] " ==== vue configuration ==== " syntax highlighting not working correctly occasionally for vue autocmd FileType vue syntax sync fromstart autocmd BufRead,BufNewFile *.vue setlocal filetype=vue " ==== closetag configuration ==== " Disables auto-close if not in a "valid" region (based on filetype) let g:closetag_regions = { \ 'typescript.tsx': 'jsxRegion,tsxRegion', \ 'javascript.jsx': 'jsxRegion', \ } let g:closetag_shortcut = '>' let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.vue,*.tsx" " ==== nerdcommenter configuration ==== " fixing vue commenting problem fu! NERDCommenter_before() if &ft == 'vue' let b:isvue = 1 let stack = synstack(line('.'), col('.')) if len(stack) > 0 let syn = synIDattr((stack)[0], 'name') if len(syn) > 0 let syn = tolower(syn) exe 'setf '.syn endif endif endif endfu fu! NERDCommenter_after() if exists('b:isvue') && b:isvue setf vue let b:isvue = 0 endif endfu " ==== general configuration ==== set ts=4 set sw=4 set listchars=eol:$,tab:->,extends:>,precedes:<,space:., set list set nu set expandtab set hidden set autoindent set confirm set noundofile set nobackup set ruler " 开启游标右下角行、列显示 set noswapfile " 关闭临时文件 set hlsearch set lazyredraw set noshowmatch set laststatus=2 let html_no_rendering=1 set fillchars=vert:\ ,fold:- set showcmd hi StatusLine cterm=NONE " 行尾空格高亮 highlight ExtraWhitespace ctermbg=red guibg=red au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red au Syntax * match ExtraWhitespace /\s\+$/ " theme try color gruvbox catch color delek endtry set background=dark highlight Normal ctermbg=None " ==== keybinding configuration ==== "vmap (fakeclip-y) inoremap ::wa nnoremap ::w vnoremap p "_dP nnoremap :noh nnoremap nt :NERDTreeToggle nnoremap fs :Grepper -tool git nnoremap o :only nnoremap q :qall nnoremap e :%s/\s\+$//g nnoremap s :syntax sync fromstart nnoremap c ::set cursorcolumn! nnoremap gs ::Gstatus nnoremap gc ::Gcommit nnoremap gp ::Gpush nnoremap gg ::Gpull nnoremap gd ::Gdiff autocmd FileType json nnoremap f %!json_pp "nnoremap m :vertical resize +5 "nnoremap , :vertical resize -5 "nnoremap . :resize +5 "nnoremap / :resize -5 "nnoremap d :vs "nnoremap [ :lprev "nnoremap ] :lnext "vnoremap m c=trim(@") . '=' . trim(system('math ' . shellescape(@"))) cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap inoremap inoremap inoremap inoremap inoremap inoremap inoremap noremap noremap noremap noremap " iterm2 插入模式时backspace不works set backspace=indent,eol,start function! DecodeHtml() exec ':%s/
/```\r/g'
  exec ':%s/<\/pre>/\r```/g'
  exec ':%s/<//g'
  exec ':%s/&/\&/g'
endfunction

function! HTML5()
  let html = []
  call setline(1, '')
  call add(html, '')
  call add(html, ' ')
  call add(html, '   ')
  call add(html, '   <++>')
  call add(html, ' ')
  call add(html, ' ')
  call add(html, ' <++>')
  call add(html, ' ')
  call add(html, '')
  call append(1, html)
endfunction