theme.lua 3.7 KB

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