commands.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. local M = {}
  2. vim.cmd [[
  3. function! QuickFixToggle()
  4. if empty(filter(getwininfo(), 'v:val.quickfix'))
  5. copen
  6. else
  7. cclose
  8. endif
  9. endfunction
  10. ]]
  11. M.defaults = {
  12. {
  13. name = "BufferKill",
  14. fn = function()
  15. require("lvim.core.bufferline").buf_kill "bd"
  16. end,
  17. },
  18. {
  19. name = "LvimToggleFormatOnSave",
  20. fn = function()
  21. require("lvim.core.autocmds").toggle_format_on_save()
  22. end,
  23. },
  24. {
  25. name = "LvimInfo",
  26. fn = function()
  27. require("lvim.core.info").toggle_popup(vim.bo.filetype)
  28. end,
  29. },
  30. {
  31. name = "LvimCacheReset",
  32. fn = function()
  33. require("lvim.utils.hooks").reset_cache()
  34. end,
  35. },
  36. {
  37. name = "LvimReload",
  38. fn = function()
  39. require("lvim.config"):reload()
  40. end,
  41. },
  42. {
  43. name = "LvimUpdate",
  44. fn = function()
  45. require("lvim.bootstrap"):update()
  46. end,
  47. },
  48. {
  49. name = "LvimSyncCorePlugins",
  50. fn = function()
  51. require("lvim.plugin-loader").sync_core_plugins()
  52. end,
  53. },
  54. {
  55. name = "LvimChangelog",
  56. fn = function()
  57. require("lvim.core.telescope.custom-finders").view_lunarvim_changelog()
  58. end,
  59. },
  60. {
  61. name = "LvimVersion",
  62. fn = function()
  63. print(require("lvim.utils.git").get_lvim_version())
  64. end,
  65. },
  66. }
  67. function M.load(collection)
  68. local common_opts = { force = true }
  69. for _, cmd in pairs(collection) do
  70. local opts = vim.tbl_deep_extend("force", common_opts, cmd.opts or {})
  71. vim.api.nvim_create_user_command(cmd.name, cmd.fn, opts)
  72. end
  73. end
  74. return M