plugins.lua 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. -- local require = require("lvim.utils.require").require
  2. local core_plugins = {
  3. { "folke/lazy.nvim", tag = "stable" },
  4. {
  5. "neovim/nvim-lspconfig",
  6. lazy = true,
  7. dependencies = { "mason-lspconfig.nvim", "nlsp-settings.nvim" },
  8. },
  9. {
  10. "williamboman/mason-lspconfig.nvim",
  11. cmd = { "LspInstall", "LspUninstall" },
  12. lazy = true,
  13. dependencies = "mason.nvim",
  14. },
  15. { "tamago324/nlsp-settings.nvim", cmd = "LspSettings", lazy = true },
  16. { "jose-elias-alvarez/null-ls.nvim", lazy = true },
  17. {
  18. "williamboman/mason.nvim",
  19. config = function()
  20. require("lvim.core.mason").setup()
  21. end,
  22. cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
  23. lazy = true,
  24. },
  25. {
  26. "folke/tokyonight.nvim",
  27. lazy = not vim.startswith(lvim.colorscheme, "tokyonight"),
  28. },
  29. {
  30. "lunarvim/lunar.nvim",
  31. lazy = lvim.colorscheme ~= "lunar",
  32. },
  33. { "Tastyep/structlog.nvim", lazy = true },
  34. { "nvim-lua/popup.nvim", lazy = true },
  35. { "nvim-lua/plenary.nvim", cmd = { "PlenaryBustedFile", "PlenaryBustedDirectory" }, lazy = true },
  36. -- Telescope
  37. {
  38. "nvim-telescope/telescope.nvim",
  39. branch = "0.1.x",
  40. config = function()
  41. require("lvim.core.telescope").setup()
  42. end,
  43. dependencies = { "telescope-fzf-native.nvim" },
  44. lazy = true,
  45. cmd = "Telescope",
  46. enabled = lvim.builtin.telescope.active,
  47. },
  48. { "nvim-telescope/telescope-fzf-native.nvim", build = "make", lazy = true, enabled = lvim.builtin.telescope.active },
  49. -- Install nvim-cmp, and buffer source as a dependency
  50. {
  51. "hrsh7th/nvim-cmp",
  52. config = function()
  53. if lvim.builtin.cmp then
  54. require("lvim.core.cmp").setup()
  55. end
  56. end,
  57. event = { "InsertEnter", "CmdlineEnter" },
  58. dependencies = {
  59. "cmp-nvim-lsp",
  60. "cmp_luasnip",
  61. "cmp-buffer",
  62. "cmp-path",
  63. "cmp-cmdline",
  64. },
  65. },
  66. { "hrsh7th/cmp-nvim-lsp", lazy = true },
  67. { "saadparwaiz1/cmp_luasnip", lazy = true },
  68. { "hrsh7th/cmp-buffer", lazy = true },
  69. { "hrsh7th/cmp-path", lazy = true },
  70. {
  71. "hrsh7th/cmp-cmdline",
  72. lazy = true,
  73. enabled = lvim.builtin.cmp and lvim.builtin.cmp.cmdline.enable or false,
  74. },
  75. {
  76. "L3MON4D3/LuaSnip",
  77. config = function()
  78. require("lvim.core.luasnip").setup()
  79. end,
  80. event = "InsertEnter",
  81. dependencies = {
  82. "friendly-snippets",
  83. },
  84. },
  85. { "rafamadriz/friendly-snippets", lazy = true, cond = lvim.builtin.luasnip.sources.friendly_snippets },
  86. {
  87. "folke/neodev.nvim",
  88. lazy = true,
  89. },
  90. -- Autopairs
  91. {
  92. "windwp/nvim-autopairs",
  93. event = "InsertEnter",
  94. config = function()
  95. require("lvim.core.autopairs").setup()
  96. end,
  97. enabled = lvim.builtin.autopairs.active,
  98. },
  99. -- Treesitter
  100. {
  101. "nvim-treesitter/nvim-treesitter",
  102. -- run = ":TSUpdate",
  103. config = function()
  104. local utils = require "lvim.utils"
  105. local path = utils.join_paths(get_runtime_dir(), "site", "pack", "lazy", "opt", "nvim-treesitter")
  106. vim.opt.rtp:prepend(path) -- treesitter needs to be before nvim's runtime in rtp
  107. require("lvim.core.treesitter").setup()
  108. end,
  109. cmd = { "TSInstall", "TSUninstall", "TSUpdate", "TSInstallInfo", "TSInstallSync", "TSInstallFromGrammar" },
  110. event = "User FileOpened",
  111. },
  112. {
  113. -- Lazy loaded by Comment.nvim pre_hook
  114. "JoosepAlviste/nvim-ts-context-commentstring",
  115. lazy = true,
  116. },
  117. -- NvimTree
  118. {
  119. "kyazdani42/nvim-tree.lua",
  120. config = function()
  121. require("lvim.core.nvimtree").setup()
  122. end,
  123. enabled = lvim.builtin.nvimtree.active,
  124. cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus", "NvimTreeFindFileToggle" },
  125. event = "User DirOpened",
  126. },
  127. -- Lir
  128. {
  129. "tamago324/lir.nvim",
  130. config = function()
  131. require("lvim.core.lir").setup()
  132. end,
  133. enabled = lvim.builtin.lir.active,
  134. event = "User DirOpened",
  135. },
  136. {
  137. "lewis6991/gitsigns.nvim",
  138. config = function()
  139. require("lvim.core.gitsigns").setup()
  140. end,
  141. event = "User FileOpened",
  142. cmd = "Gitsigns",
  143. enabled = lvim.builtin.gitsigns.active,
  144. },
  145. -- Whichkey
  146. {
  147. "folke/which-key.nvim",
  148. config = function()
  149. require("lvim.core.which-key").setup()
  150. end,
  151. cmd = "WhichKey",
  152. event = "VeryLazy",
  153. enabled = lvim.builtin.which_key.active,
  154. },
  155. -- Comments
  156. {
  157. "numToStr/Comment.nvim",
  158. config = function()
  159. require("lvim.core.comment").setup()
  160. end,
  161. keys = { { "gc", mode = { "n", "v" } }, { "gb", mode = { "n", "v" } } },
  162. event = "User FileOpened",
  163. enabled = lvim.builtin.comment.active,
  164. },
  165. -- project.nvim
  166. {
  167. "ahmedkhalf/project.nvim",
  168. config = function()
  169. require("lvim.core.project").setup()
  170. end,
  171. enabled = lvim.builtin.project.active,
  172. event = "VimEnter",
  173. cmd = "Telescope projects",
  174. },
  175. -- Icons
  176. {
  177. "nvim-tree/nvim-web-devicons",
  178. enabled = lvim.use_icons,
  179. lazy = true,
  180. },
  181. -- Status Line and Bufferline
  182. {
  183. -- "hoob3rt/lualine.nvim",
  184. "nvim-lualine/lualine.nvim",
  185. -- "Lunarvim/lualine.nvim",
  186. config = function()
  187. require("lvim.core.lualine").setup()
  188. end,
  189. event = "VimEnter",
  190. enabled = lvim.builtin.lualine.active,
  191. },
  192. -- breadcrumbs
  193. {
  194. "SmiteshP/nvim-navic",
  195. config = function()
  196. require("lvim.core.breadcrumbs").setup()
  197. end,
  198. event = "User FileOpened",
  199. enabled = lvim.builtin.breadcrumbs.active,
  200. },
  201. {
  202. "akinsho/bufferline.nvim",
  203. config = function()
  204. require("lvim.core.bufferline").setup()
  205. end,
  206. branch = "main",
  207. event = "User FileOpened",
  208. enabled = lvim.builtin.bufferline.active,
  209. },
  210. -- Debugging
  211. {
  212. "mfussenegger/nvim-dap",
  213. config = function()
  214. require("lvim.core.dap").setup()
  215. end,
  216. lazy = true,
  217. enabled = lvim.builtin.dap.active,
  218. },
  219. -- Debugger user interface
  220. {
  221. "rcarriga/nvim-dap-ui",
  222. config = function()
  223. require("lvim.core.dap").setup_ui()
  224. end,
  225. lazy = true,
  226. enabled = lvim.builtin.dap.active,
  227. },
  228. -- alpha
  229. {
  230. "goolord/alpha-nvim",
  231. config = function()
  232. require("lvim.core.alpha").setup()
  233. end,
  234. enabled = lvim.builtin.alpha.active,
  235. event = "VimEnter",
  236. },
  237. -- Terminal
  238. {
  239. "akinsho/toggleterm.nvim",
  240. event = "VeryLazy",
  241. branch = "main",
  242. config = function()
  243. require("lvim.core.terminal").setup()
  244. end,
  245. enabled = lvim.builtin.terminal.active,
  246. },
  247. -- SchemaStore
  248. {
  249. "b0o/schemastore.nvim",
  250. lazy = true,
  251. },
  252. {
  253. "RRethy/vim-illuminate",
  254. config = function()
  255. require("lvim.core.illuminate").setup()
  256. end,
  257. event = "User FileOpened",
  258. enabled = lvim.builtin.illuminate.active,
  259. },
  260. {
  261. "lukas-reineke/indent-blankline.nvim",
  262. config = function()
  263. require("lvim.core.indentlines").setup()
  264. end,
  265. event = "User FileOpened",
  266. enabled = lvim.builtin.indentlines.active,
  267. },
  268. {
  269. "lunarvim/onedarker.nvim",
  270. branch = "freeze",
  271. config = function()
  272. pcall(function()
  273. if lvim and lvim.colorscheme == "onedarker" then
  274. require("onedarker").setup()
  275. lvim.builtin.lualine.options.theme = "onedarker"
  276. end
  277. end)
  278. end,
  279. lazy = lvim.colorscheme ~= "onedarker",
  280. },
  281. {
  282. "lunarvim/bigfile.nvim",
  283. config = function()
  284. pcall(function()
  285. require("bigfile").config(lvim.builtin.bigfile.config)
  286. end)
  287. end,
  288. enabled = lvim.builtin.bigfile.active,
  289. event = { "FileReadPre", "BufReadPre", "User FileOpened" },
  290. },
  291. }
  292. local default_snapshot_path = join_paths(get_lvim_base_dir(), "snapshots", "default.json")
  293. local content = vim.fn.readfile(default_snapshot_path)
  294. local default_sha1 = assert(vim.fn.json_decode(content))
  295. -- taken form <https://github.com/folke/lazy.nvim/blob/c7122d64cdf16766433588486adcee67571de6d0/lua/lazy/core/plugin.lua#L27>
  296. local get_short_name = function(long_name)
  297. local name = long_name:sub(-4) == ".git" and long_name:sub(1, -5) or long_name
  298. local slash = name:reverse():find("/", 1, true) --[[@as number?]]
  299. return slash and name:sub(#name - slash + 2) or long_name:gsub("%W+", "_")
  300. end
  301. local get_default_sha1 = function(spec)
  302. local short_name = get_short_name(spec[1])
  303. return default_sha1[short_name] and default_sha1[short_name].commit
  304. end
  305. if not vim.env.LVIM_DEV_MODE then
  306. -- Manually lock the commit hashes of core plugins
  307. for _, spec in ipairs(core_plugins) do
  308. spec["commit"] = get_default_sha1(spec)
  309. end
  310. end
  311. return core_plugins