init.lua 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. -- galaxyline themes for Gruvbox and NVCode.
  25. -- Uncomment and change 'colors_colorschemeName'
  26. -- to 'colors' to enable.
  27. -- Colors for Gruvbox
  28. -- local colors_gruvbox = {
  29. -- bg = '#32302F',
  30. -- yellow = '#FABD2F',
  31. -- dark_yellow = '#D79921',
  32. -- cyan = '#689D6A',
  33. -- green = '#608B4E',
  34. -- light_green = '#B8BB26',
  35. -- string_orange = '#D65D0E',
  36. -- orange = '#FE8019',
  37. -- purple = '#B16286',
  38. -- magenta = '#D3869B',
  39. -- grey = '#A89984',
  40. -- blue = '#458588',
  41. -- -- vivid_blue = '#4FC1FF',
  42. -- light_blue = '#83A598',
  43. -- red = '#FB4834',
  44. -- error_red = '#CC241D',
  45. -- info_yellow = '#D79921'
  46. -- }
  47. -- colors for NVCode theme (very minimal changes)
  48. -- local colors_nvcode = {
  49. -- bg = '#2E2E2E',
  50. -- yellow = '#DCDCAA',
  51. -- dark_yellow = '#D7BA7D',
  52. -- cyan = '#4EC9B0',
  53. -- green = '#608B4E',
  54. -- light_green = '#B5CEA8',
  55. -- string_orange = '#CE9178',
  56. -- orange = '#FF8800',
  57. -- purple = '#C586C0',
  58. -- magenta = '#D16D9E',
  59. -- grey = '#729CB3',
  60. -- blue = '#569CD6',
  61. -- vivid_blue = '#4FC1FF',
  62. -- light_blue = '#9CDCFE',
  63. -- red = '#D16969',
  64. -- error_red = '#F44747',
  65. -- info_yellow = '#FFCC66'
  66. -- }
  67. local condition = require('galaxyline.condition')
  68. local gls = gl.section
  69. gl.short_line_list = {'NvimTree', 'vista', 'dbui', 'packer'}
  70. table.insert(gls.left, {
  71. ViMode = {
  72. provider = function()
  73. -- auto change color according the vim mode
  74. local mode_color = {
  75. n = colors.blue,
  76. i = colors.green,
  77. v = colors.purple,
  78. [''] = colors.purple,
  79. V = colors.purple,
  80. c = colors.magenta,
  81. no = colors.blue,
  82. s = colors.orange,
  83. S = colors.orange,
  84. [''] = colors.orange,
  85. ic = colors.yellow,
  86. R = colors.red,
  87. Rv = colors.red,
  88. cv = colors.blue,
  89. ce = colors.blue,
  90. r = colors.cyan,
  91. rm = colors.cyan,
  92. ['r?'] = colors.cyan,
  93. ['!'] = colors.blue,
  94. t = colors.blue
  95. }
  96. vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
  97. return '▊ '
  98. end,
  99. highlight = {colors.red, colors.bg}
  100. }
  101. })
  102. -- print(vim.fn.getbufvar(0, 'ts'))
  103. vim.fn.getbufvar(0, 'ts')
  104. table.insert(gls.left, {
  105. GitIcon = {
  106. provider = function()
  107. return ' '
  108. end,
  109. condition = condition.check_git_workspace,
  110. separator = ' ',
  111. separator_highlight = {'NONE', colors.bg},
  112. highlight = {colors.orange, colors.bg}
  113. }
  114. })
  115. table.insert(gls.left, {
  116. GitBranch = {
  117. provider = 'GitBranch',
  118. condition = condition.check_git_workspace,
  119. separator = ' ',
  120. separator_highlight = {'NONE', colors.bg},
  121. highlight = {colors.grey, colors.bg}
  122. }
  123. })
  124. table.insert(gls.left, {
  125. DiffAdd = {
  126. provider = 'DiffAdd',
  127. condition = condition.hide_in_width,
  128. icon = '  ',
  129. highlight = {colors.green, colors.bg}
  130. }
  131. })
  132. table.insert(gls.left, {
  133. DiffModified = {
  134. provider = 'DiffModified',
  135. condition = condition.hide_in_width,
  136. icon = ' 柳',
  137. highlight = {colors.blue, colors.bg}
  138. }
  139. })
  140. table.insert(gls.left, {
  141. DiffRemove = {
  142. provider = 'DiffRemove',
  143. condition = condition.hide_in_width,
  144. icon = '  ',
  145. highlight = {colors.red, colors.bg}
  146. }
  147. })
  148. table.insert(gls.right, {
  149. DiagnosticError = {provider = 'DiagnosticError', icon = '  ', highlight = {colors.error_red, colors.bg}}
  150. })
  151. table.insert(gls.right, {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = '  ', highlight = {colors.orange, colors.bg}}})
  152. table.insert(gls.right, {
  153. DiagnosticHint = {provider = 'DiagnosticHint', icon = '  ', highlight = {colors.vivid_blue, colors.bg}}
  154. })
  155. table.insert(gls.right, {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = '  ', highlight = {colors.info_yellow, colors.bg}}})
  156. table.insert(gls.right, {
  157. TreesitterIcon = {
  158. provider = function()
  159. if next(vim.treesitter.highlighter.active) ~= nil then return ' ' end
  160. return ''
  161. end,
  162. separator = ' ',
  163. separator_highlight = {'NONE', colors.bg},
  164. highlight = {colors.green, colors.bg}
  165. }
  166. })
  167. local get_lsp_client = function (msg)
  168. msg = msg or "No Active LSP Client"
  169. local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
  170. local clients = vim.lsp.get_active_clients()
  171. if next(clients) == nil then
  172. return msg
  173. end
  174. local lsps = ""
  175. for _,client in ipairs(clients) do
  176. local filetypes = client.config.filetypes
  177. if filetypes and vim.fn.index(filetypes, buf_ft) ~=1 then
  178. -- print(client.name)
  179. if lsps == "" then
  180. -- print("first", lsps)
  181. lsps = client.name
  182. else
  183. lsps = lsps .. ", " .. client.name
  184. -- print("more", lsps)
  185. end
  186. end
  187. end
  188. if lsps == "" then
  189. return msg
  190. else
  191. return lsps
  192. end
  193. end
  194. table.insert(gls.right, {
  195. ShowLspClient = {
  196. provider = get_lsp_client,
  197. condition = function()
  198. local tbl = {['dashboard'] = true, [' '] = true}
  199. if tbl[vim.bo.filetype] then return false end
  200. return true
  201. end,
  202. icon = ' ',
  203. highlight = {colors.grey, colors.bg}
  204. }
  205. })
  206. table.insert(gls.right, {
  207. LineInfo = {
  208. provider = 'LineColumn',
  209. separator = ' ',
  210. separator_highlight = {'NONE', colors.bg},
  211. highlight = {colors.grey, colors.bg}
  212. }
  213. })
  214. table.insert(gls.right, {
  215. PerCent = {
  216. provider = 'LinePercent',
  217. separator = ' ',
  218. separator_highlight = {'NONE', colors.bg},
  219. highlight = {colors.grey, colors.bg}
  220. }
  221. })
  222. table.insert(gls.right, {
  223. Tabstop = {
  224. provider = function()
  225. return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
  226. end,
  227. condition = condition.hide_in_width,
  228. separator = ' ',
  229. separator_highlight = {'NONE', colors.bg},
  230. highlight = {colors.grey, colors.bg}
  231. }
  232. })
  233. table.insert(gls.right, {
  234. BufferType = {
  235. provider = 'FileTypeName',
  236. condition = condition.hide_in_width,
  237. separator = ' ',
  238. separator_highlight = {'NONE', colors.bg},
  239. highlight = {colors.grey, colors.bg}
  240. }
  241. })
  242. table.insert(gls.right, {
  243. FileEncode = {
  244. provider = 'FileEncode',
  245. condition = condition.hide_in_width,
  246. separator = ' ',
  247. separator_highlight = {'NONE', colors.bg},
  248. highlight = {colors.grey, colors.bg}
  249. }
  250. })
  251. table.insert(gls.right, {
  252. Space = {
  253. provider = function()
  254. return ' '
  255. end,
  256. separator = ' ',
  257. separator_highlight = {'NONE', colors.bg},
  258. highlight = {colors.orange, colors.bg}
  259. }
  260. })
  261. table.insert(gls.short_line_left, {
  262. BufferType = {
  263. provider = 'FileTypeName',
  264. separator = ' ',
  265. separator_highlight = {'NONE', colors.bg},
  266. highlight = {colors.grey, colors.bg}
  267. }
  268. })
  269. table.insert(gls.short_line_left, {
  270. SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty, highlight = {colors.grey, colors.bg}}
  271. })
  272. --table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})