styles.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 = { left = "", right = "" },
  44. section_separators = { left = "", right = "" },
  45. disabled_filetypes = {},
  46. },
  47. sections = {
  48. lualine_a = { "mode" },
  49. lualine_b = { "branch" },
  50. lualine_c = { "filename" },
  51. lualine_x = { "encoding", "fileformat", "filetype" },
  52. lualine_y = { "progress" },
  53. lualine_z = { "location" },
  54. },
  55. inactive_sections = {
  56. lualine_a = {},
  57. lualine_b = {},
  58. lualine_c = { "filename" },
  59. lualine_x = { "location" },
  60. lualine_y = {},
  61. lualine_z = {},
  62. },
  63. tabline = {},
  64. extensions = {},
  65. }
  66. styles.lvim = {
  67. style = "lvim",
  68. options = {
  69. theme = "auto",
  70. globalstatus = true,
  71. icons_enabled = lvim.use_icons,
  72. component_separators = { left = "", right = "" },
  73. section_separators = { left = "", right = "" },
  74. disabled_filetypes = { "alpha", "NvimTree", "Outline" },
  75. },
  76. sections = {
  77. lualine_a = {
  78. components.mode,
  79. },
  80. lualine_b = {
  81. components.branch,
  82. },
  83. lualine_c = {
  84. components.diff,
  85. components.python_env,
  86. },
  87. lualine_x = {
  88. components.diagnostics,
  89. components.lsp,
  90. components.spaces,
  91. components.filetype,
  92. },
  93. lualine_y = { components.location },
  94. lualine_z = {
  95. components.progress,
  96. },
  97. },
  98. inactive_sections = {
  99. lualine_a = {
  100. components.mode,
  101. },
  102. lualine_b = {
  103. components.branch,
  104. },
  105. lualine_c = {
  106. components.diff,
  107. components.python_env,
  108. },
  109. lualine_x = {
  110. components.diagnostics,
  111. components.lsp,
  112. components.spaces,
  113. components.filetype,
  114. },
  115. lualine_y = { components.location },
  116. lualine_z = {
  117. components.progress,
  118. },
  119. },
  120. tabline = {},
  121. extensions = { "nvim-tree" },
  122. }
  123. function M.get_style(style)
  124. local style_keys = vim.tbl_keys(styles)
  125. if not vim.tbl_contains(style_keys, style) then
  126. local Log = require "lvim.core.log"
  127. Log:error(
  128. "Invalid lualine style"
  129. .. string.format('"%s"', style)
  130. .. "options are: "
  131. .. string.format('"%s"', table.concat(style_keys, '", "'))
  132. )
  133. Log:debug '"lvim" style is applied.'
  134. style = "lvim"
  135. end
  136. return vim.deepcopy(styles[style])
  137. end
  138. function M.update()
  139. local style = M.get_style(lvim.builtin.lualine.style)
  140. lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style)
  141. end
  142. return M