plugins.lua 9.6 KB

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