commands.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 = "LvimDocs",
  32. fn = function()
  33. local documentation_url = "https://www.lunarvim.org/docs/beginners-guide"
  34. if vim.fn.has "mac" == 1 or vim.fn.has "macunix" == 1 then
  35. vim.fn.execute("!open " .. documentation_url)
  36. elseif vim.fn.has "win32" == 1 or vim.fn.has "win64" == 1 then
  37. vim.fn.execute("!start " .. documentation_url)
  38. elseif vim.fn.has "unix" == 1 then
  39. vim.fn.execute("!xdg-open " .. documentation_url)
  40. else
  41. vim.notify "Opening docs in a browser is not supported on your OS"
  42. end
  43. end,
  44. },
  45. {
  46. name = "LvimCacheReset",
  47. fn = function()
  48. require("lvim.utils.hooks").reset_cache()
  49. end,
  50. },
  51. {
  52. name = "LvimReload",
  53. fn = function()
  54. require("lvim.config"):reload()
  55. end,
  56. },
  57. {
  58. name = "LvimUpdate",
  59. fn = function()
  60. require("lvim.bootstrap"):update()
  61. end,
  62. },
  63. {
  64. name = "LvimSyncCorePlugins",
  65. fn = function()
  66. require("lvim.plugin-loader").sync_core_plugins()
  67. end,
  68. },
  69. {
  70. name = "LvimChangelog",
  71. fn = function()
  72. require("lvim.core.telescope.custom-finders").view_lunarvim_changelog()
  73. end,
  74. },
  75. {
  76. name = "LvimVersion",
  77. fn = function()
  78. print(require("lvim.utils.git").get_lvim_version())
  79. end,
  80. },
  81. {
  82. name = "LvimOpenlog",
  83. fn = function()
  84. vim.fn.execute("edit " .. require("lvim.core.log").get_path())
  85. end,
  86. },
  87. }
  88. function M.load(collection)
  89. local common_opts = { force = true }
  90. for _, cmd in pairs(collection) do
  91. local opts = vim.tbl_deep_extend("force", common_opts, cmd.opts or {})
  92. vim.api.nvim_create_user_command(cmd.name, cmd.fn, opts)
  93. end
  94. end
  95. return M