plugins.lua 9.4 KB

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