plugins.lua 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. branch = "legacy",
  182. config = function()
  183. require("plugin-config.fidget")
  184. end,
  185. })
  186. -- 颜色高亮
  187. use("norcalli/nvim-colorizer.lua")
  188. use({
  189. "folke/noice.nvim",
  190. requires = {
  191. { "MunifTanjim/nui.nvim" },
  192. },
  193. })
  194. use({
  195. "smjonas/inc-rename.nvim",
  196. config = function()
  197. require("inc_rename").setup()
  198. end,
  199. })
  200. -- smooth scroll
  201. use({
  202. "karb94/neoscroll.nvim",
  203. config = function()
  204. require("plugin-config.neoscroll")
  205. end,
  206. })
  207. -- code action menu
  208. use({
  209. "weilbith/nvim-code-action-menu",
  210. cmd = "CodeActionMenu",
  211. })
  212. use({
  213. "nacro90/numb.nvim",
  214. config = function()
  215. require("numb").setup()
  216. end,
  217. })
  218. use("echasnovski/mini.nvim")
  219. -- git merge diff view
  220. use("sindrets/diffview.nvim")
  221. end,
  222. config = {
  223. -- 并发数限制
  224. max_jobs = 16,
  225. -- 自定义源
  226. git = {
  227. -- default_url_format = "https://hub.fastgit.xyz/%s",
  228. -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s"
  229. -- default_url_format = "https://gitcode.net/mirrors/%s"
  230. -- default_url_format = "https://gitclone.com/github.com/%s",
  231. },
  232. display = {
  233. open_fn = function()
  234. return require("packer.util").float({
  235. border = "single",
  236. })
  237. end,
  238. },
  239. },
  240. })
  241. -- 每次保存 plugins.lua 自动安装插件
  242. pcall(
  243. vim.cmd,
  244. [[
  245. augroup packer_user_config
  246. autocmd!
  247. autocmd BufWritePost plugins.lua source <afile> | PackerSync
  248. augroup end
  249. ]]
  250. )