plugins.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. use('nvim-tree/nvim-web-devicons')
  38. -- tokyonight 主题
  39. use("folke/tokyonight.nvim")
  40. -- nvim-tree 文件侧边栏
  41. use({
  42. "kyazdani42/nvim-tree.lua",
  43. requires = "kyazdani42/nvim-web-devicons"
  44. })
  45. -- 文件搜索
  46. use {
  47. 'nvim-telescope/telescope.nvim',
  48. requires = { "nvim-lua/plenary.nvim" }
  49. }
  50. -- dashboard-nvim vim 主页
  51. use {
  52. 'glepnir/dashboard-nvim',
  53. requires = { 'nvim-tree/nvim-web-devicons' }
  54. }
  55. use 'voldikss/vim-floaterm'
  56. -- project
  57. use("ahmedkhalf/project.nvim")
  58. -- treesitter (新增)
  59. use {
  60. 'nvim-treesitter/nvim-treesitter',
  61. run = ':TSUpdate'
  62. }
  63. use('nvim-treesitter/nvim-tree-docs')
  64. --------------------- LSP --------------------
  65. use {
  66. 'neoclide/coc.nvim',
  67. branch = 'release'
  68. }
  69. -- 自动关闭标签
  70. use {'windwp/nvim-ts-autotag'}
  71. -- Lspconfig
  72. use({ "neovim/nvim-lspconfig" })
  73. use({"L3MON4D3/LuaSnip",run = "make install_jsregexp"})
  74. -- git
  75. use {'lewis6991/gitsigns.nvim'}
  76. -- lazygit
  77. use({
  78. "kdheepak/lazygit.nvim",
  79. -- optional for floating window border decoration
  80. requires = {
  81. "nvim-lua/plenary.nvim",
  82. },
  83. })
  84. -- eslint
  85. use ('MunifTanjim/eslint.nvim')
  86. -- indent
  87. use("nathanaelkane/vim-indent-guides")
  88. -- 闭合高亮
  89. use ('leafOfTree/vim-matchtag')
  90. --use("hrsh7th/nvim-cmp")
  91. -- snippet 引擎
  92. -- 补全源
  93. --use("hrsh7th/cmp-vsnip")
  94. --use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }
  95. --use("hrsh7th/cmp-buffer") -- { name = 'buffer' },
  96. --use("hrsh7th/cmp-path") -- { name = 'path' }
  97. --use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' }
  98. -- 常见编程语言代码段
  99. use("rafamadriz/friendly-snippets")
  100. -- 括号自动补全
  101. use {
  102. "windwp/nvim-autopairs",
  103. config = function()
  104. require("nvim-autopairs").setup {}
  105. end
  106. }
  107. -- 代码格式化
  108. use('jose-elias-alvarez/null-ls.nvim')
  109. use('MunifTanjim/prettier.nvim')
  110. use {
  111. 'numToStr/Comment.nvim',
  112. config = function()
  113. require('Comment').setup()
  114. end
  115. }
  116. end,
  117. config = {
  118. -- 并发数限制
  119. max_jobs = 16,
  120. -- 自定义源
  121. git = {
  122. -- default_url_format = "https://hub.fastgit.xyz/%s",
  123. -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s"
  124. -- default_url_format = "https://gitcode.net/mirrors/%s"
  125. -- default_url_format = "https://gitclone.com/github.com/%s",
  126. },
  127. display = {
  128. open_fn = function()
  129. return require("packer.util").float({
  130. border = "single"
  131. })
  132. end
  133. }
  134. }
  135. })
  136. -- 每次保存 plugins.lua 自动安装插件
  137. pcall(vim.cmd, [[
  138. augroup packer_user_config
  139. autocmd!
  140. autocmd BufWritePost plugins.lua source <afile> | PackerSync
  141. augroup end
  142. ]])