plugins.lua 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim",
  10. -- "https://gitcode.net/mirrors/wbthomason/packer.nvim",
  11. install_path})
  12. -- https://github.com/wbthomason/packer.nvim/issues/750
  13. local rtp_addition = vim.fn.stdpath("data") .. "/site/pack/*/start/*"
  14. if not string.find(vim.o.runtimepath, rtp_addition) then
  15. vim.o.runtimepath = rtp_addition .. "," .. vim.o.runtimepath
  16. end
  17. vim.notify("Pakcer.nvim 安装完毕")
  18. end
  19. -- Use a protected call so we don't error out on first use
  20. local status_ok, packer = pcall(require, "packer")
  21. if not status_ok then
  22. vim.notify("没有安装 packer.nvim")
  23. return
  24. end
  25. packer.startup({
  26. function(use)
  27. -- Packer 可以管理自己本身
  28. use 'wbthomason/packer.nvim'
  29. -- 你的插件列表...
  30. use {
  31. 'nvim-lualine/lualine.nvim',
  32. requires = {
  33. 'nvim-tree/nvim-web-devicons',
  34. opt = true
  35. }
  36. }
  37. -- tokyonight 主题
  38. use("folke/tokyonight.nvim")
  39. -- nvim-tree 文件侧边栏
  40. use({
  41. "kyazdani42/nvim-tree.lua",
  42. requires = "kyazdani42/nvim-web-devicons"
  43. })
  44. -- 文件搜索
  45. use {
  46. 'nvim-telescope/telescope.nvim',
  47. requires = {"nvim-lua/plenary.nvim"}
  48. }
  49. -- dashboard-nvim vim 主页
  50. use {
  51. 'glepnir/dashboard-nvim',
  52. event = 'VimEnter',
  53. requires = {'nvim-tree/nvim-web-devicons'}
  54. }
  55. -- project
  56. use("ahmedkhalf/project.nvim")
  57. -- treesitter (新增)
  58. use({
  59. "nvim-treesitter/nvim-treesitter",
  60. run = ":TSUpdate"
  61. })
  62. end,
  63. config = {
  64. -- 并发数限制
  65. max_jobs = 16,
  66. -- 自定义源
  67. git = {
  68. -- default_url_format = "https://hub.fastgit.xyz/%s",
  69. -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s",
  70. -- default_url_format = "https://gitcode.net/mirrors/%s",
  71. -- default_url_format = "https://gitclone.com/github.com/%s",
  72. },
  73. display = {
  74. open_fn = function()
  75. return require("packer.util").float({
  76. border = "single"
  77. })
  78. end
  79. }
  80. }
  81. })
  82. -- 每次保存 plugins.lua 自动安装插件
  83. pcall(vim.cmd, [[
  84. augroup packer_user_config
  85. autocmd!
  86. autocmd BufWritePost plugins.lua source <afile> | PackerSync
  87. augroup end
  88. ]])