styles.lua 2.9 KB

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