plugins.lua 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. -- 悬浮终端
  56. use 'voldikss/vim-floaterm'
  57. -- project
  58. use("ahmedkhalf/project.nvim")
  59. -- treesitter 代码高亮
  60. use {
  61. 'nvim-treesitter/nvim-treesitter',
  62. run = ':TSUpdate',
  63. requires = {
  64. { "p00f/nvim-ts-rainbow" },
  65. { "JoosepAlviste/nvim-ts-context-commentstring" },
  66. { "windwp/nvim-ts-autotag" },
  67. { "nvim-treesitter/nvim-treesitter-refactor" },
  68. { "nvim-treesitter/nvim-treesitter-textobjects" },
  69. },
  70. config = function()
  71. require("plugin-config.nvim-treesitter")
  72. end,
  73. }
  74. use('nvim-treesitter/nvim-tree-docs')
  75. --------------------- LSP --------------------
  76. -- use {
  77. -- 'neoclide/coc.nvim',
  78. -- branch = 'release'
  79. -- }
  80. -- mason
  81. use {
  82. "williamboman/mason.nvim",
  83. run = ":MasonUpdate" -- :MasonUpdate updates registry contents
  84. }
  85. use("williamboman/mason-lspconfig.nvim")
  86. use({ "neovim/nvim-lspconfig" })
  87. use("hrsh7th/nvim-cmp") -- completion plugin
  88. use("hrsh7th/cmp-nvim-lsp")
  89. use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters
  90. use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls
  91. use("onsails/lspkind.nvim")
  92. -- 自动关闭标签
  93. use { 'windwp/nvim-ts-autotag' }
  94. -- snippet 引擎
  95. use({ "L3MON4D3/LuaSnip", run = "make install_jsregexp" })
  96. use("hrsh7th/vim-vsnip")
  97. -- 补全源
  98. use("hrsh7th/cmp-vsnip")
  99. --use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }
  100. use("hrsh7th/cmp-buffer") -- { name = 'buffer' },
  101. use("hrsh7th/cmp-path") -- { name = 'path' }
  102. use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' }
  103. -- 常见编程语言代码段
  104. use("rafamadriz/friendly-snippets")
  105. -- git
  106. use { 'lewis6991/gitsigns.nvim' }
  107. -- lazygit
  108. use({
  109. "kdheepak/lazygit.nvim",
  110. -- optional for floating window border decoration
  111. requires = {
  112. "nvim-lua/plenary.nvim",
  113. },
  114. })
  115. -- eslint
  116. use('MunifTanjim/eslint.nvim')
  117. -- indent
  118. use("lukas-reineke/indent-blankline.nvim")
  119. -- 闭合高亮
  120. use('leafOfTree/vim-matchtag')
  121. -- 切换窗口大小
  122. use("szw/vim-maximizer")
  123. -- 错误提示
  124. use({ "folke/trouble.nvim", requires = "kyazdani42/nvim-web-devicons" })
  125. -- 括号自动补全
  126. use {
  127. "windwp/nvim-autopairs",
  128. config = function()
  129. require("nvim-autopairs").setup {}
  130. end
  131. }
  132. -- 代码格式化
  133. use('MunifTanjim/prettier.nvim')
  134. -- 代码注释 gcc
  135. use {
  136. 'numToStr/Comment.nvim',
  137. config = function()
  138. require('Comment').setup()
  139. end
  140. }
  141. -- hop 快速跳转
  142. use {
  143. 'phaazon/hop.nvim',
  144. branch = 'v2', -- optional but strongly recommended
  145. config = function()
  146. -- you can configure Hop the way you like here; see :h hop-config
  147. require'hop'.setup { keys = 'etovxqpdygfblzhckisuran' }
  148. end
  149. }
  150. -- lspsage
  151. use("tami5/lspsaga.nvim")
  152. -- TypeScript 增强
  153. use({ "jose-elias-alvarez/nvim-lsp-ts-utils", requires = "nvim-lua/plenary.nvim" })
  154. use("jose-elias-alvarez/typescript.nvim")
  155. -- formatter
  156. use("mhartington/formatter.nvim")
  157. -- lua 增强
  158. use("folke/neodev.nvim")
  159. --json 增强
  160. use("b0o/schemastore.nvim")
  161. -- Rust 增强
  162. use("simrat39/rust-tools.nvim")
  163. -- 彩虹括号
  164. use("p00f/nvim-ts-rainbow")
  165. -- nvim-notify
  166. use({
  167. "rcarriga/nvim-notify",
  168. config = function()
  169. require("plugin-config.nvim-notify")
  170. end,
  171. })
  172. -- fidget.nvim
  173. use({
  174. "j-hui/fidget.nvim",
  175. config = function()
  176. require("plugin-config.fidget")
  177. end,
  178. })
  179. end,
  180. config = {
  181. -- 并发数限制
  182. max_jobs = 16,
  183. -- 自定义源
  184. git = {
  185. -- default_url_format = "https://hub.fastgit.xyz/%s",
  186. -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s"
  187. -- default_url_format = "https://gitcode.net/mirrors/%s"
  188. -- default_url_format = "https://gitclone.com/github.com/%s",
  189. },
  190. display = {
  191. open_fn = function()
  192. return require("packer.util").float({
  193. border = "single"
  194. })
  195. end
  196. }
  197. }
  198. })
  199. -- 每次保存 plugins.lua 自动安装插件
  200. pcall(vim.cmd, [[
  201. augroup packer_user_config
  202. autocmd!
  203. autocmd BufWritePost plugins.lua source <afile> | PackerSync
  204. augroup end
  205. ]])