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