plugins.vim 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. " auto-install vim-plug
  2. if empty(glob('~/.config/nvim/autoload/plug.vim'))
  3. silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
  4. \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  5. "autocmd VimEnter * PlugInstall
  6. "autocmd VimEnter * PlugInstall | source $MYVIMRC
  7. endif
  8. call plug#begin('~/.config/nvim/autoload/plugged')
  9. " Better Syntax Support
  10. Plug 'sheerun/vim-polyglot'
  11. " File Explorer
  12. Plug 'scrooloose/NERDTree'
  13. " Auto pairs for '(' '[' '{'
  14. Plug 'jiangmiao/auto-pairs'
  15. " Themes
  16. Plug 'joshdick/onedark.vim'
  17. call plug#end()
  18. " Automatically install missing plugins on startup
  19. autocmd VimEnter *
  20. \ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
  21. \| PlugInstall --sync | q
  22. \| endif
  23. " Press gx to open the GitHub URL for a plugin or a commit with the default browser.
  24. function! s:plug_gx()
  25. let line = getline('.')
  26. let sha = matchstr(line, '^ \X*\zs\x\{7,9}\ze ')
  27. let name = empty(sha) ? matchstr(line, '^[-x+] \zs[^:]\+\ze:')
  28. \ : getline(search('^- .*:$', 'bn'))[2:-2]
  29. let uri = get(get(g:plugs, name, {}), 'uri', '')
  30. if uri !~ 'github.com'
  31. return
  32. endif
  33. let repo = matchstr(uri, '[^:/]*/'.name)
  34. let url = empty(sha) ? 'https://github.com/'.repo
  35. \ : printf('https://github.com/%s/commit/%s', repo, sha)
  36. call netrw#BrowseX(url, 0)
  37. endfunction
  38. augroup PlugGx
  39. autocmd!
  40. autocmd FileType vim-plug nnoremap <buffer> <silent> gx :call <sid>plug_gx()<cr>
  41. augroup END