plugins.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. -- 自动安装 Packer.nvim
  2. -- 插件安装目录
  3. -- ~/.local/share/nvim/site/pack/packer/
  4. local fn = vim.fn
  5. local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
  6. local paccker_bootstrap
  7. if fn.empty(fn.glob(install_path)) > 0 then
  8. vim.notify("正在安装Pakcer.nvim,请稍后...")
  9. paccker_bootstrap = fn.system({
  10. "git",
  11. "clone",
  12. "--depth",
  13. "1",
  14. "https://github.com/wbthomason/packer.nvim",
  15. -- "https://gitcode.net/mirrors/wbthomason/packer.nvim",
  16. install_path,
  17. })
  18. -- https://github.com/wbthomason/packer.nvim/issues/750
  19. local rtp_addition = vim.fn.stdpath("data") .. "/site/pack/*/start/*"
  20. if not string.find(vim.o.runtimepath, rtp_addition) then
  21. vim.o.runtimepath = rtp_addition .. "," .. vim.o.runtimepath
  22. end
  23. vim.notify("Pakcer.nvim 安装完毕")
  24. end
  25. -- Use a protected call so we don't error out on first use
  26. local status_ok, packer = pcall(require, "packer")
  27. if not status_ok then
  28. vim.notify("没有安装 packer.nvim")
  29. return
  30. end
  31. packer.startup({
  32. function(use)
  33. -- Packer 可以升级自己
  34. use("wbthomason/packer.nvim")
  35. -------------------------- plugins -------------------------------------------
  36. -- nvim-tree
  37. use({
  38. "kyazdani42/nvim-tree.lua",
  39. requires = "kyazdani42/nvim-web-devicons",
  40. })
  41. -- lualine
  42. use {
  43. 'nvim-lualine/lualine.nvim',
  44. requires = { 'nvim-tree/nvim-web-devicons', opt = true }
  45. }
  46. end,
  47. config = {
  48. -- 最大并发数
  49. max_jobs = 16,
  50. -- 自定义源
  51. git = {
  52. -- default_url_format = "https://hub.fastgit.xyz/%s",
  53. -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s",
  54. -- default_url_format = "https://gitcode.net/mirrors/%s",
  55. -- default_url_format = "https://gitclone.com/github.com/%s",
  56. },
  57. display = {
  58. -- 使用浮动窗口显示
  59. open_fn = function()
  60. return require("packer.util").float({ border = "single" })
  61. end,
  62. },
  63. },
  64. })
  65. -- 每次保存 plugins.lua 自动安装插件
  66. -- move to autocmds.lua
  67. -- pcall(
  68. -- vim.cmd,
  69. -- [[
  70. -- augroup packer_user_config
  71. -- autocmd!
  72. -- autocmd BufWritePost plugins.lua source <afile> | PackerSync
  73. -- augroup end
  74. -- ]]
  75. -- )