styles.lua 2.9 KB

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