theme.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. local Log = require "lvim.core.log"
  2. local M = {}
  3. M.config = function()
  4. lvim.builtin.theme = {
  5. name = "lunar",
  6. lunar = {
  7. options = { -- currently unused
  8. },
  9. },
  10. }
  11. end
  12. M.setup = function()
  13. -- avoid running in headless mode since it's harder to detect failures
  14. if #vim.api.nvim_list_uis() == 0 then
  15. Log:debug "headless mode detected, skipping running setup for lualine"
  16. return
  17. end
  18. local selected_theme = lvim.builtin.theme.name
  19. if vim.startswith(lvim.colorscheme, selected_theme) then
  20. local status_ok, plugin = pcall(require, selected_theme)
  21. if not status_ok then
  22. return
  23. end
  24. pcall(function()
  25. plugin.setup(lvim.builtin.theme[selected_theme].options)
  26. end)
  27. end
  28. -- ref: https://github.com/neovim/neovim/issues/18201#issuecomment-1104754564
  29. local colors = vim.api.nvim_get_runtime_file(("colors/%s.*"):format(lvim.colorscheme), false)
  30. if #colors == 0 then
  31. Log:debug(string.format("Could not find '%s' colorscheme", lvim.colorscheme))
  32. return
  33. end
  34. vim.g.colors_name = lvim.colorscheme
  35. vim.cmd("colorscheme " .. lvim.colorscheme)
  36. require("lvim.core.lualine").setup()
  37. require("lvim.core.lir").icon_setup()
  38. end
  39. return M