styles.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. icons_enabled = lvim.use_icons,
  13. component_separators = { left = "", right = "" },
  14. section_separators = { left = "", right = "" },
  15. disabled_filetypes = {},
  16. },
  17. sections = {
  18. lualine_a = {},
  19. lualine_b = {},
  20. lualine_c = {},
  21. lualine_x = {},
  22. lualine_y = {},
  23. lualine_z = {},
  24. },
  25. inactive_sections = {
  26. lualine_a = {},
  27. lualine_b = {},
  28. lualine_c = {},
  29. lualine_x = {},
  30. lualine_y = {},
  31. lualine_z = {},
  32. },
  33. tabline = {},
  34. extensions = {},
  35. }
  36. styles.default = {
  37. style = "default",
  38. options = {
  39. theme = "auto",
  40. icons_enabled = lvim.use_icons,
  41. component_separators = { left = "", right = "" },
  42. section_separators = { left = "", right = "" },
  43. disabled_filetypes = {},
  44. },
  45. sections = {
  46. lualine_a = { "mode" },
  47. lualine_b = { "branch" },
  48. lualine_c = { "filename" },
  49. lualine_x = { "encoding", "fileformat", "filetype" },
  50. lualine_y = { "progress" },
  51. lualine_z = { "location" },
  52. },
  53. inactive_sections = {
  54. lualine_a = {},
  55. lualine_b = {},
  56. lualine_c = { "filename" },
  57. lualine_x = { "location" },
  58. lualine_y = {},
  59. lualine_z = {},
  60. },
  61. tabline = {},
  62. extensions = {},
  63. }
  64. styles.lvim = {
  65. style = "lvim",
  66. options = {
  67. theme = "auto",
  68. icons_enabled = lvim.use_icons,
  69. component_separators = { left = "", right = "" },
  70. section_separators = { left = "", right = "" },
  71. disabled_filetypes = { "alpha", "NvimTree", "Outline" },
  72. },
  73. sections = {
  74. lualine_a = {
  75. components.mode,
  76. },
  77. lualine_b = {
  78. components.branch,
  79. },
  80. lualine_c = {
  81. components.diff,
  82. components.python_env,
  83. },
  84. lualine_x = {
  85. components.diagnostics,
  86. components.lsp,
  87. components.filetype,
  88. },
  89. lualine_y = { components.location },
  90. lualine_z = {
  91. components.progress,
  92. },
  93. },
  94. inactive_sections = {
  95. lualine_a = {
  96. "filename",
  97. },
  98. lualine_b = {},
  99. lualine_c = {},
  100. lualine_x = {},
  101. lualine_y = {},
  102. lualine_z = {},
  103. },
  104. tabline = {},
  105. extensions = { "nvim-tree" },
  106. }
  107. function M.get_style(style)
  108. local style_keys = vim.tbl_keys(styles)
  109. if not vim.tbl_contains(style_keys, style) then
  110. local Log = require "lvim.core.log"
  111. Log:error(
  112. "Invalid lualine style"
  113. .. string.format('"%s"', style)
  114. .. "options are: "
  115. .. string.format('"%s"', table.concat(style_keys, '", "'))
  116. )
  117. Log:debug '"lvim" style is applied.'
  118. style = "lvim"
  119. end
  120. return vim.deepcopy(styles[style])
  121. end
  122. function M.update()
  123. local style = M.get_style(lvim.builtin.lualine.style)
  124. lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style)
  125. end
  126. return M