theme.lua 3.0 KB

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