init.lua 8.1 KB

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