plugins.lua 6.4 KB

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