plugins.lua 9.6 KB

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