plugins.lua 9.8 KB

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