plugins.lua 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. local utils = require "lvim.utils"
  79. local paths = {}
  80. if lvim.builtin.luasnip.sources.friendly_snippets then
  81. paths[#paths + 1] = utils.join_paths(get_runtime_dir(), "site", "pack", "lazy", "opt", "friendly-snippets")
  82. end
  83. local user_snippets = utils.join_paths(get_config_dir(), "snippets")
  84. if utils.is_directory(user_snippets) then
  85. paths[#paths + 1] = user_snippets
  86. end
  87. require("luasnip.loaders.from_lua").lazy_load()
  88. require("luasnip.loaders.from_vscode").lazy_load {
  89. paths = paths,
  90. }
  91. require("luasnip.loaders.from_snipmate").lazy_load()
  92. end,
  93. event = "InsertEnter",
  94. dependencies = {
  95. "friendly-snippets",
  96. },
  97. },
  98. { "rafamadriz/friendly-snippets", lazy = true, cond = lvim.builtin.luasnip.sources.friendly_snippets },
  99. {
  100. "folke/neodev.nvim",
  101. lazy = true,
  102. },
  103. -- Autopairs
  104. {
  105. "windwp/nvim-autopairs",
  106. event = "InsertEnter",
  107. config = function()
  108. require("lvim.core.autopairs").setup()
  109. end,
  110. enabled = lvim.builtin.autopairs.active,
  111. },
  112. -- Treesitter
  113. {
  114. "nvim-treesitter/nvim-treesitter",
  115. -- run = ":TSUpdate",
  116. config = function()
  117. local utils = require "lvim.utils"
  118. local path = utils.join_paths(get_runtime_dir(), "site", "pack", "lazy", "opt", "nvim-treesitter")
  119. vim.opt.rtp:prepend(path) -- treesitter needs to be before nvim's runtime in rtp
  120. require("lvim.core.treesitter").setup()
  121. end,
  122. cmd = { "TSInstall", "TSUninstall", "TSUpdate", "TSInstallInfo", "TSInstallSync", "TSInstallFromGrammar" },
  123. event = "User FileOpened",
  124. },
  125. {
  126. -- Lazy loaded by Comment.nvim pre_hook
  127. "JoosepAlviste/nvim-ts-context-commentstring",
  128. lazy = true,
  129. },
  130. -- NvimTree
  131. {
  132. "kyazdani42/nvim-tree.lua",
  133. config = function()
  134. require("lvim.core.nvimtree").setup()
  135. end,
  136. enabled = lvim.builtin.nvimtree.active,
  137. cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus", "NvimTreeFindFileToggle" },
  138. event = "User DirOpened",
  139. },
  140. -- Lir
  141. {
  142. "tamago324/lir.nvim",
  143. config = function()
  144. require("lvim.core.lir").setup()
  145. end,
  146. enabled = lvim.builtin.lir.active,
  147. event = "User DirOpened",
  148. },
  149. {
  150. "lewis6991/gitsigns.nvim",
  151. config = function()
  152. require("lvim.core.gitsigns").setup()
  153. end,
  154. event = "User FileOpened",
  155. cmd = "Gitsigns",
  156. enabled = lvim.builtin.gitsigns.active,
  157. },
  158. -- Whichkey
  159. {
  160. "folke/which-key.nvim",
  161. config = function()
  162. require("lvim.core.which-key").setup()
  163. end,
  164. cmd = "WhichKey",
  165. event = "VeryLazy",
  166. enabled = lvim.builtin.which_key.active,
  167. },
  168. -- Comments
  169. {
  170. "numToStr/Comment.nvim",
  171. config = function()
  172. require("lvim.core.comment").setup()
  173. end,
  174. keys = { { "gc", mode = { "n", "v" } }, { "gb", mode = { "n", "v" } } },
  175. event = "User FileOpened",
  176. enabled = lvim.builtin.comment.active,
  177. },
  178. -- project.nvim
  179. {
  180. "ahmedkhalf/project.nvim",
  181. config = function()
  182. require("lvim.core.project").setup()
  183. end,
  184. enabled = lvim.builtin.project.active,
  185. event = "VimEnter",
  186. cmd = "Telescope projects",
  187. },
  188. -- Icons
  189. {
  190. "nvim-tree/nvim-web-devicons",
  191. enabled = lvim.use_icons,
  192. lazy = true,
  193. },
  194. -- Status Line and Bufferline
  195. {
  196. -- "hoob3rt/lualine.nvim",
  197. "nvim-lualine/lualine.nvim",
  198. -- "Lunarvim/lualine.nvim",
  199. config = function()
  200. require("lvim.core.lualine").setup()
  201. end,
  202. event = "VimEnter",
  203. enabled = lvim.builtin.lualine.active,
  204. },
  205. -- breadcrumbs
  206. {
  207. "SmiteshP/nvim-navic",
  208. config = function()
  209. require("lvim.core.breadcrumbs").setup()
  210. end,
  211. event = "User FileOpened",
  212. enabled = lvim.builtin.breadcrumbs.active,
  213. },
  214. {
  215. "akinsho/bufferline.nvim",
  216. config = function()
  217. require("lvim.core.bufferline").setup()
  218. end,
  219. branch = "main",
  220. event = "User FileOpened",
  221. enabled = lvim.builtin.bufferline.active,
  222. },
  223. -- Debugging
  224. {
  225. "mfussenegger/nvim-dap",
  226. config = function()
  227. require("lvim.core.dap").setup()
  228. end,
  229. lazy = true,
  230. enabled = lvim.builtin.dap.active,
  231. },
  232. -- Debugger user interface
  233. {
  234. "rcarriga/nvim-dap-ui",
  235. config = function()
  236. require("lvim.core.dap").setup_ui()
  237. end,
  238. lazy = true,
  239. enabled = lvim.builtin.dap.active,
  240. },
  241. -- alpha
  242. {
  243. "goolord/alpha-nvim",
  244. config = function()
  245. require("lvim.core.alpha").setup()
  246. end,
  247. enabled = lvim.builtin.alpha.active,
  248. event = "VimEnter",
  249. },
  250. -- Terminal
  251. {
  252. "akinsho/toggleterm.nvim",
  253. event = "VeryLazy",
  254. branch = "main",
  255. config = function()
  256. require("lvim.core.terminal").setup()
  257. end,
  258. enabled = lvim.builtin.terminal.active,
  259. },
  260. -- SchemaStore
  261. {
  262. "b0o/schemastore.nvim",
  263. lazy = true,
  264. },
  265. {
  266. "RRethy/vim-illuminate",
  267. config = function()
  268. require("lvim.core.illuminate").setup()
  269. end,
  270. event = "User FileOpened",
  271. enabled = lvim.builtin.illuminate.active,
  272. },
  273. {
  274. "lukas-reineke/indent-blankline.nvim",
  275. config = function()
  276. require("lvim.core.indentlines").setup()
  277. end,
  278. event = "User FileOpened",
  279. enabled = lvim.builtin.indentlines.active,
  280. },
  281. {
  282. "lunarvim/onedarker.nvim",
  283. branch = "freeze",
  284. config = function()
  285. pcall(function()
  286. if lvim and lvim.colorscheme == "onedarker" then
  287. require("onedarker").setup()
  288. lvim.builtin.lualine.options.theme = "onedarker"
  289. end
  290. end)
  291. end,
  292. lazy = lvim.colorscheme ~= "onedarker",
  293. },
  294. {
  295. "lunarvim/bigfile.nvim",
  296. config = function()
  297. pcall(function()
  298. require("bigfile").config(lvim.builtin.bigfile.config)
  299. end)
  300. end,
  301. enabled = lvim.builtin.bigfile.active,
  302. event = { "FileReadPre", "BufReadPre", "User FileOpened" },
  303. },
  304. }
  305. local default_snapshot_path = join_paths(get_lvim_base_dir(), "snapshots", "default.json")
  306. local content = vim.fn.readfile(default_snapshot_path)
  307. local default_sha1 = assert(vim.fn.json_decode(content))
  308. -- taken form <https://github.com/folke/lazy.nvim/blob/c7122d64cdf16766433588486adcee67571de6d0/lua/lazy/core/plugin.lua#L27>
  309. local get_short_name = function(long_name)
  310. local name = long_name:sub(-4) == ".git" and long_name:sub(1, -5) or long_name
  311. local slash = name:reverse():find("/", 1, true) --[[@as number?]]
  312. return slash and name:sub(#name - slash + 2) or long_name:gsub("%W+", "_")
  313. end
  314. local get_default_sha1 = function(spec)
  315. local short_name = get_short_name(spec[1])
  316. return default_sha1[short_name] and default_sha1[short_name].commit
  317. end
  318. if not vim.env.LVIM_DEV_MODE then
  319. -- Manually lock the commit hashes of core plugins
  320. for _, spec in ipairs(core_plugins) do
  321. spec["commit"] = get_default_sha1(spec)
  322. end
  323. end
  324. return core_plugins