styles.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. local M = {}
  2. local components = require "lvim.core.lualine.components"
  3. local styles = {
  4. lvim = nil,
  5. default = nil,
  6. none = nil,
  7. }
  8. styles.none = {
  9. style = "none",
  10. options = {
  11. theme = "auto",
  12. globalstatus = true,
  13. icons_enabled = lvim.use_icons,
  14. component_separators = { left = "", right = "" },
  15. section_separators = { left = "", right = "" },
  16. disabled_filetypes = {},
  17. },
  18. sections = {
  19. lualine_a = {},
  20. lualine_b = {},
  21. lualine_c = {},
  22. lualine_x = {},
  23. lualine_y = {},
  24. lualine_z = {},
  25. },
  26. inactive_sections = {
  27. lualine_a = {},
  28. lualine_b = {},
  29. lualine_c = {},
  30. lualine_x = {},
  31. lualine_y = {},
  32. lualine_z = {},
  33. },
  34. tabline = {},
  35. extensions = {},
  36. }
  37. styles.default = {
  38. style = "default",
  39. options = {
  40. theme = "auto",
  41. globalstatus = true,
  42. icons_enabled = lvim.use_icons,
  43. component_separators = {
  44. left = lvim.icons.ui.DividerRight,
  45. right = lvim.icons.ui.DividerLeft,
  46. },
  47. section_separators = {
  48. left = lvim.icons.ui.BoldDividerRight,
  49. right = lvim.icons.ui.BoldDividerLeft,
  50. },
  51. disabled_filetypes = {},
  52. },
  53. sections = {
  54. lualine_a = { "mode" },
  55. lualine_b = { "branch" },
  56. lualine_c = { "filename" },
  57. lualine_x = { "encoding", "fileformat", "filetype" },
  58. lualine_y = { "progress" },
  59. lualine_z = { "location" },
  60. },
  61. inactive_sections = {
  62. lualine_a = {},
  63. lualine_b = {},
  64. lualine_c = { "filename" },
  65. lualine_x = { "location" },
  66. lualine_y = {},
  67. lualine_z = {},
  68. },
  69. tabline = {},
  70. extensions = {},
  71. }
  72. styles.lvim = {
  73. style = "lvim",
  74. options = {
  75. theme = "auto",
  76. globalstatus = true,
  77. icons_enabled = lvim.use_icons,
  78. component_separators = { left = "", right = "" },
  79. section_separators = { left = "", right = "" },
  80. disabled_filetypes = { "alpha" },
  81. },
  82. sections = {
  83. lualine_a = {
  84. components.mode,
  85. },
  86. lualine_b = {
  87. components.branch,
  88. },
  89. lualine_c = {
  90. components.diff,
  91. components.python_env,
  92. },
  93. lualine_x = {
  94. components.diagnostics,
  95. components.lsp,
  96. components.spaces,
  97. components.filetype,
  98. },
  99. lualine_y = { components.location },
  100. lualine_z = {
  101. components.progress,
  102. },
  103. },
  104. inactive_sections = {
  105. lualine_a = {
  106. components.mode,
  107. },
  108. lualine_b = {
  109. components.branch,
  110. },
  111. lualine_c = {
  112. components.diff,
  113. components.python_env,
  114. },
  115. lualine_x = {
  116. components.diagnostics,
  117. components.lsp,
  118. components.spaces,
  119. components.filetype,
  120. },
  121. lualine_y = { components.location },
  122. lualine_z = {
  123. components.progress,
  124. },
  125. },
  126. tabline = {},
  127. extensions = {},
  128. }
  129. function M.get_style(style)
  130. local style_keys = vim.tbl_keys(styles)
  131. if not vim.tbl_contains(style_keys, style) then
  132. local Log = require "lvim.core.log"
  133. Log:error(
  134. "Invalid lualine style"
  135. .. string.format('"%s"', style)
  136. .. "options are: "
  137. .. string.format('"%s"', table.concat(style_keys, '", "'))
  138. )
  139. Log:debug '"lvim" style is applied.'
  140. style = "lvim"
  141. end
  142. return vim.deepcopy(styles[style])
  143. end
  144. function M.update()
  145. local style = M.get_style(lvim.builtin.lualine.style)
  146. lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style)
  147. local color_template = vim.g.colors_name or lvim.colorscheme
  148. local theme_supported, template = pcall(function()
  149. require("lualine.utils.loader").load_theme(color_template)
  150. end)
  151. if theme_supported and template then
  152. lvim.builtin.lualine.options.theme = color_template
  153. end
  154. end
  155. return M