plugins.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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({
  125. "lukas-reineke/indent-blankline.nvim",
  126. config = function()
  127. require("ibl").setup({})
  128. end,
  129. })
  130. -- use("lukas-reineke/indent-blankline.nvim")
  131. -- 闭合高亮
  132. use("leafOfTree/vim-matchtag")
  133. -- 切换窗口大小
  134. use("szw/vim-maximizer")
  135. -- 错误提示
  136. use({ "folke/trouble.nvim", requires = "kyazdani42/nvim-web-devicons" })
  137. -- 括号自动补全
  138. use({
  139. "windwp/nvim-autopairs",
  140. config = function()
  141. require("nvim-autopairs").setup({})
  142. end,
  143. })
  144. -- 代码注释 gcc
  145. use({
  146. "numToStr/Comment.nvim",
  147. config = function()
  148. require("Comment").setup()
  149. end,
  150. })
  151. -- hop 快速跳转
  152. use({
  153. "phaazon/hop.nvim",
  154. branch = "v2", -- optional but strongly recommended
  155. config = function()
  156. -- you can configure Hop the way you like here; see :h hop-config
  157. require("hop").setup({ keys = "etovxqpdygfblzhckisuran" })
  158. end,
  159. })
  160. -- lspsage
  161. use("tami5/lspsaga.nvim")
  162. -- TypeScript 增强
  163. use({ "jose-elias-alvarez/nvim-lsp-ts-utils", requires = "nvim-lua/plenary.nvim" })
  164. use("jose-elias-alvarez/typescript.nvim")
  165. -- 代码格式化
  166. use("MunifTanjim/prettier.nvim")
  167. use("mhartington/formatter.nvim")
  168. use({ "jose-elias-alvarez/null-ls.nvim", requires = "nvim-lua/plenary.nvim" })
  169. -- lua 增强
  170. use("folke/neodev.nvim")
  171. --json 增强
  172. use("b0o/schemastore.nvim")
  173. -- Rust 增强
  174. use("simrat39/rust-tools.nvim")
  175. -- 彩虹括号
  176. use("p00f/nvim-ts-rainbow")
  177. -- nvim-notify
  178. use({
  179. "rcarriga/nvim-notify",
  180. config = function()
  181. require("plugin-config.nvim-notify")
  182. end,
  183. })
  184. -- fidget.nvim
  185. use({
  186. "j-hui/fidget.nvim",
  187. tag = "legacy",
  188. config = function()
  189. require("plugin-config.fidget")
  190. end,
  191. })
  192. -- 颜色高亮
  193. use("norcalli/nvim-colorizer.lua")
  194. use({
  195. "folke/noice.nvim",
  196. requires = {
  197. { "MunifTanjim/nui.nvim" },
  198. },
  199. })
  200. use({
  201. "smjonas/inc-rename.nvim",
  202. config = function()
  203. require("inc_rename").setup()
  204. end,
  205. })
  206. end,
  207. config = {
  208. -- 并发数限制
  209. max_jobs = 16,
  210. -- 自定义源
  211. git = {
  212. -- default_url_format = "https://hub.fastgit.xyz/%s",
  213. -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s"
  214. -- default_url_format = "https://gitcode.net/mirrors/%s"
  215. -- default_url_format = "https://gitclone.com/github.com/%s",
  216. },
  217. display = {
  218. open_fn = function()
  219. return require("packer.util").float({
  220. border = "single",
  221. })
  222. end,
  223. },
  224. },
  225. })
  226. -- 每次保存 plugins.lua 自动安装插件
  227. pcall(
  228. vim.cmd,
  229. [[
  230. augroup packer_user_config
  231. autocmd!
  232. autocmd BufWritePost plugins.lua source <afile> | PackerSync
  233. augroup end
  234. ]]
  235. )