theme.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. tokyonight = {
  11. options = {
  12. on_highlights = function(hl, c)
  13. hl.IndentBlanklineContextChar = {
  14. fg = c.dark5,
  15. }
  16. hl.TSConstructor = {
  17. fg = c.blue1,
  18. }
  19. hl.TSTagDelimiter = {
  20. fg = c.dark5,
  21. }
  22. end,
  23. style = "night", -- The theme comes in three styles, `storm`, a darker variant `night` and `day`
  24. transparent = lvim.transparent_window, -- Enable this to disable setting the background color
  25. terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim
  26. styles = {
  27. -- Style to be applied to different syntax groups
  28. -- Value is any valid attr-list value for `:help nvim_set_hl`
  29. comments = { italic = true },
  30. keywords = { italic = true },
  31. functions = {},
  32. variables = {},
  33. -- Background styles. Can be "dark", "transparent" or "normal"
  34. sidebars = "dark", -- style for sidebars, see below
  35. floats = "dark", -- style for floating windows
  36. },
  37. -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
  38. sidebars = {
  39. "qf",
  40. "vista_kind",
  41. "terminal",
  42. "packer",
  43. "spectre_panel",
  44. "NeogitStatus",
  45. "help",
  46. },
  47. day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
  48. hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
  49. dim_inactive = false, -- dims inactive windows
  50. lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold
  51. use_background = true, -- can be light/dark/auto. When auto, background will be set to vim.o.background
  52. },
  53. },
  54. }
  55. end
  56. M.setup = function()
  57. -- avoid running in headless mode since it's harder to detect failures
  58. if #vim.api.nvim_list_uis() == 0 then
  59. Log:debug "headless mode detected, skipping running setup for lualine"
  60. return
  61. end
  62. local selected_theme = lvim.builtin.theme.name
  63. if vim.startswith(lvim.colorscheme, selected_theme) then
  64. local status_ok, plugin = pcall(require, selected_theme)
  65. if not status_ok then
  66. return
  67. end
  68. pcall(function()
  69. plugin.setup(lvim.builtin.theme[selected_theme].options)
  70. end)
  71. end
  72. -- ref: https://github.com/neovim/neovim/issues/18201#issuecomment-1104754564
  73. local colors = vim.api.nvim_get_runtime_file(("colors/%s.*"):format(lvim.colorscheme), false)
  74. if #colors == 0 then
  75. Log:debug(string.format("Could not find '%s' colorscheme", lvim.colorscheme))
  76. return
  77. end
  78. vim.g.colors_name = lvim.colorscheme
  79. vim.cmd("colorscheme " .. lvim.colorscheme)
  80. if package.loaded.lualine then
  81. require("lvim.core.lualine").setup()
  82. end
  83. if package.loaded.lir then
  84. require("lvim.core.lir").icon_setup()
  85. end
  86. end
  87. return M