init.lua 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. local gl = require('galaxyline')
  2. -- get my theme in galaxyline repo
  3. -- local colors = require('galaxyline.theme').default
  4. local colors = {
  5. -- bg = '#2E2E2E',
  6. bg = '#292D38',
  7. yellow = '#DCDCAA',
  8. dark_yellow = '#D7BA7D',
  9. cyan = '#4EC9B0',
  10. green = '#608B4E',
  11. light_green = '#B5CEA8',
  12. string_orange = '#CE9178',
  13. orange = '#FF8800',
  14. purple = '#C586C0',
  15. magenta = '#D16D9E',
  16. grey = '#858585',
  17. blue = '#569CD6',
  18. vivid_blue = '#4FC1FF',
  19. light_blue = '#9CDCFE',
  20. red = '#D16969',
  21. error_red = '#F44747',
  22. info_yellow = '#FFCC66'
  23. }
  24. local condition = require('galaxyline.condition')
  25. local gls = gl.section
  26. gl.short_line_list = {'NvimTree', 'vista', 'dbui', 'packer'}
  27. gls.left[1] = {
  28. ViMode = {
  29. provider = function()
  30. -- auto change color according the vim mode
  31. local mode_color = {
  32. n = colors.blue,
  33. i = colors.green,
  34. v = colors.purple,
  35. [''] = colors.purple,
  36. V = colors.purple,
  37. c = colors.magenta,
  38. no = colors.blue,
  39. s = colors.orange,
  40. S = colors.orange,
  41. [''] = colors.orange,
  42. ic = colors.yellow,
  43. R = colors.red,
  44. Rv = colors.red,
  45. cv = colors.blue,
  46. ce = colors.blue,
  47. r = colors.cyan,
  48. rm = colors.cyan,
  49. ['r?'] = colors.cyan,
  50. ['!'] = colors.blue,
  51. t = colors.blue
  52. }
  53. vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
  54. return '▊ '
  55. end,
  56. highlight = {colors.red, colors.bg}
  57. }
  58. }
  59. print(vim.fn.getbufvar(0, 'ts'))
  60. vim.fn.getbufvar(0, 'ts')
  61. gls.left[2] = {
  62. GitIcon = {
  63. provider = function()
  64. return ' '
  65. end,
  66. condition = condition.check_git_workspace,
  67. separator = ' ',
  68. separator_highlight = {'NONE', colors.bg},
  69. highlight = {colors.orange, colors.bg}
  70. }
  71. }
  72. gls.left[3] = {
  73. GitBranch = {
  74. provider = 'GitBranch',
  75. condition = condition.check_git_workspace,
  76. separator = ' ',
  77. separator_highlight = {'NONE', colors.bg},
  78. highlight = {colors.grey, colors.bg}
  79. }
  80. }
  81. gls.left[4] = {
  82. DiffAdd = {
  83. provider = 'DiffAdd',
  84. condition = condition.hide_in_width,
  85. icon = '  ',
  86. highlight = {colors.green, colors.bg}
  87. }
  88. }
  89. gls.left[5] = {
  90. DiffModified = {
  91. provider = 'DiffModified',
  92. condition = condition.hide_in_width,
  93. icon = ' 柳',
  94. highlight = {colors.blue, colors.bg}
  95. }
  96. }
  97. gls.left[6] = {
  98. DiffRemove = {
  99. provider = 'DiffRemove',
  100. condition = condition.hide_in_width,
  101. icon = '  ',
  102. highlight = {colors.red, colors.bg}
  103. }
  104. }
  105. gls.right[1] = {
  106. DiagnosticError = {provider = 'DiagnosticError', icon = '  ', highlight = {colors.error_red, colors.bg}}
  107. }
  108. gls.right[2] = {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = '  ', highlight = {colors.orange, colors.bg}}}
  109. gls.right[3] = {
  110. DiagnosticHint = {provider = 'DiagnosticHint', icon = '  ', highlight = {colors.vivid_blue, colors.bg}}
  111. }
  112. gls.right[4] = {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = '  ', highlight = {colors.info_yellow, colors.bg}}}
  113. gls.right[5] = {
  114. TreesitterIcon = {
  115. provider = function()
  116. if next(vim.treesitter.highlighter.active) ~= nil then return ' ' end
  117. return ''
  118. end,
  119. separator = ' ',
  120. separator_highlight = {'NONE', colors.bg},
  121. highlight = {colors.green, colors.bg}
  122. }
  123. }
  124. gls.right[6] = {
  125. ShowLspClient = {
  126. provider = 'GetLspClient',
  127. condition = function()
  128. local tbl = {['dashboard'] = true, [' '] = true}
  129. if tbl[vim.bo.filetype] then return false end
  130. return true
  131. end,
  132. icon = ' ',
  133. highlight = {colors.grey, colors.bg}
  134. }
  135. }
  136. gls.right[7] = {
  137. LineInfo = {
  138. provider = 'LineColumn',
  139. separator = ' ',
  140. separator_highlight = {'NONE', colors.bg},
  141. highlight = {colors.grey, colors.bg}
  142. }
  143. }
  144. gls.right[8] = {
  145. PerCent = {
  146. provider = 'LinePercent',
  147. separator = ' ',
  148. separator_highlight = {'NONE', colors.bg},
  149. highlight = {colors.grey, colors.bg}
  150. }
  151. }
  152. gls.right[9] = {
  153. Tabstop = {
  154. provider = function()
  155. return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
  156. end,
  157. condition = condition.hide_in_width,
  158. separator = ' ',
  159. separator_highlight = {'NONE', colors.bg},
  160. highlight = {colors.grey, colors.bg}
  161. }
  162. }
  163. gls.right[10] = {
  164. BufferType = {
  165. provider = 'FileTypeName',
  166. condition = condition.hide_in_width,
  167. separator = ' ',
  168. separator_highlight = {'NONE', colors.bg},
  169. highlight = {colors.grey, colors.bg}
  170. }
  171. }
  172. gls.right[11] = {
  173. FileEncode = {
  174. provider = 'FileEncode',
  175. condition = condition.hide_in_width,
  176. separator = ' ',
  177. separator_highlight = {'NONE', colors.bg},
  178. highlight = {colors.grey, colors.bg}
  179. }
  180. }
  181. gls.right[12] = {
  182. Space = {
  183. provider = function()
  184. return ' '
  185. end,
  186. separator = ' ',
  187. separator_highlight = {'NONE', colors.bg},
  188. highlight = {colors.orange, colors.bg}
  189. }
  190. }
  191. gls.short_line_left[1] = {
  192. BufferType = {
  193. provider = 'FileTypeName',
  194. separator = ' ',
  195. separator_highlight = {'NONE', colors.bg},
  196. highlight = {colors.grey, colors.bg}
  197. }
  198. }
  199. gls.short_line_left[2] = {
  200. SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.grey, colors.bg}}
  201. }
  202. gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}}