_deprecated.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ---@diagnostic disable: deprecated
  2. local M = {}
  3. local function deprecate(name, alternative)
  4. local in_headless = #vim.api.nvim_list_uis() == 0
  5. if in_headless then
  6. return
  7. end
  8. alternative = alternative or "See https://github.com/LunarVim/LunarVim#breaking-changes"
  9. local trace = debug.getinfo(3, "Sl")
  10. local shorter_src = trace.short_src
  11. local t = shorter_src .. ":" .. (trace.currentline or trace.lastlinedefined)
  12. vim.schedule(function()
  13. vim.notify_once(string.format("%s: `%s` is deprecated.\n %s.", t, name, alternative), vim.log.levels.WARN)
  14. end)
  15. end
  16. function M.handle()
  17. local mt = {
  18. __newindex = function(_, k, _)
  19. deprecate(k)
  20. end,
  21. }
  22. ---@deprecated
  23. lvim.builtin.theme.options = {}
  24. setmetatable(lvim.builtin.theme.options, {
  25. __newindex = function(_, k, v)
  26. deprecate("lvim.builtin.theme.options." .. k, "Use `lvim.builtin.theme.<theme>.options` instead")
  27. lvim.builtin.theme.tokyonight.options[k] = v
  28. end,
  29. })
  30. ---@deprecated
  31. lvim.builtin.notify = {}
  32. setmetatable(lvim.builtin.notify, {
  33. __newindex = function(_, k, _)
  34. deprecate("lvim.builtin.notify." .. k, "See LunarVim#3294")
  35. end,
  36. })
  37. if lvim.lsp.override and not vim.tbl_isempty(lvim.lsp.override) then
  38. deprecate("lvim.lsp.override", "Use `lvim.lsp.automatic_configuration.skipped_servers` instead")
  39. vim.tbl_map(function(c)
  40. if not vim.tbl_contains(lvim.lsp.automatic_configuration.skipped_servers, c) then
  41. table.insert(lvim.lsp.automatic_configuration.skipped_servers, c)
  42. end
  43. end, lvim.lsp.override)
  44. end
  45. if lvim.autocommands.custom_groups then
  46. deprecate(
  47. "lvim.autocommands.custom_groups",
  48. "Use vim.api.nvim_create_autocmd instead or check LunarVim#2592 to learn about the new syntax"
  49. )
  50. end
  51. if lvim.lsp.automatic_servers_installation then
  52. deprecate(
  53. "lvim.lsp.automatic_servers_installation",
  54. "Use `lvim.lsp.installer.setup.automatic_installation` instead"
  55. )
  56. end
  57. ---@deprecated
  58. lvim.builtin.dashboard = {}
  59. setmetatable(lvim.builtin.dashboard, {
  60. __newindex = function(_, k, _)
  61. deprecate("lvim.builtin.dashboard." .. k, "Use `lvim.builtin.alpha` instead. See LunarVim#1906")
  62. end,
  63. })
  64. ---@deprecated
  65. lvim.lsp.popup_border = {}
  66. setmetatable(lvim.lsp.popup_border, mt)
  67. ---@deprecated
  68. lvim.lang = {}
  69. setmetatable(lvim.lang, mt)
  70. ---@deprecated
  71. lvim.builtin.theme.tokyonight = {}
  72. local tokyonight_deprecation = function(t, k, v)
  73. lvim.colorscheme = "lunar"
  74. deprecate(
  75. "lvim.builtin.theme.tokyonight." .. k,
  76. "tokyonight was removed from core plugins, configure it like this <https://www.lunarvim.org/docs/master/configuration/plugins/example-configurations#tokyonight>"
  77. )
  78. rawset(t, k, v ~= nil and v or {})
  79. return t[k]
  80. end
  81. setmetatable(lvim.builtin.theme.tokyonight, {
  82. __newindex = tokyonight_deprecation,
  83. __index = tokyonight_deprecation,
  84. })
  85. end
  86. return M