styles.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. icons_enabled = lvim.use_icons,
  71. component_separators = { left = "", right = "" },
  72. section_separators = { left = "", right = "" },
  73. disabled_filetypes = { "alpha", "NvimTree", "Outline" },
  74. },
  75. sections = {
  76. lualine_a = {
  77. components.mode,
  78. },
  79. lualine_b = {
  80. components.branch,
  81. },
  82. lualine_c = {
  83. components.diff,
  84. components.python_env,
  85. },
  86. lualine_x = {
  87. components.diagnostics,
  88. components.lsp,
  89. components.spaces,
  90. components.filetype,
  91. },
  92. lualine_y = { components.location },
  93. lualine_z = {
  94. components.progress,
  95. },
  96. },
  97. inactive_sections = {
  98. lualine_a = {
  99. "filename",
  100. },
  101. lualine_b = {},
  102. lualine_c = {},
  103. lualine_x = {},
  104. lualine_y = {},
  105. lualine_z = {},
  106. },
  107. tabline = {},
  108. extensions = { "nvim-tree" },
  109. }
  110. function M.get_style(style)
  111. local style_keys = vim.tbl_keys(styles)
  112. if not vim.tbl_contains(style_keys, style) then
  113. local Log = require "lvim.core.log"
  114. Log:error(
  115. "Invalid lualine style"
  116. .. string.format('"%s"', style)
  117. .. "options are: "
  118. .. string.format('"%s"', table.concat(style_keys, '", "'))
  119. )
  120. Log:debug '"lvim" style is applied.'
  121. style = "lvim"
  122. end
  123. return vim.deepcopy(styles[style])
  124. end
  125. function M.update()
  126. local style = M.get_style(lvim.builtin.lualine.style)
  127. lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style)
  128. end
  129. return M