plugins.lua 9.5 KB

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