plugins.lua 9.3 KB

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