init.lua 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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 = 'TabLineSel'
  103. -- highlight = {colors.red, colors.bg}
  104. }
  105. })
  106. -- print(vim.fn.getbufvar(0, 'ts'))
  107. vim.fn.getbufvar(0, 'ts')
  108. table.insert(gls.left, {
  109. GitIcon = {
  110. provider = function()
  111. return ' '
  112. end,
  113. condition = condition.check_git_workspace,
  114. separator = ' ',
  115. separator_highlight = 'StatusLineSeparator',
  116. highlight = 'StatusLineGit'
  117. }
  118. })
  119. table.insert(gls.left, {
  120. GitBranch = {
  121. provider = 'GitBranch',
  122. condition = condition.check_git_workspace,
  123. separator = ' ',
  124. separator_highlight = 'StatusLineSeparator',
  125. highlight = 'StatusLineNC'
  126. }
  127. })
  128. table.insert(gls.left, {
  129. DiffAdd = {
  130. provider = 'DiffAdd',
  131. condition = condition.hide_in_width,
  132. icon = '  ',
  133. highlight = 'StatusLineGitAdd'
  134. }
  135. })
  136. table.insert(gls.left, {
  137. DiffModified = {
  138. provider = 'DiffModified',
  139. condition = condition.hide_in_width,
  140. icon = ' 柳',
  141. highlight = 'StatusLineGitChange'
  142. }
  143. })
  144. table.insert(gls.left, {
  145. DiffRemove = {
  146. provider = 'DiffRemove',
  147. condition = condition.hide_in_width,
  148. icon = '  ',
  149. highlight = 'StatusLineGitDelete'
  150. }
  151. })
  152. table.insert(gls.right, {
  153. DiagnosticError = {provider = 'DiagnosticError', icon = '  ',
  154. highlight = 'StatusLineLspDiagnosticsError'
  155. }
  156. })
  157. table.insert(gls.right, {DiagnosticWarn = {provider = 'DiagnosticWarn', icon = '  ',
  158. highlight = 'StatusLineLspDiagnosticsWarning'
  159. }})
  160. table.insert(gls.right, {DiagnosticInfo = {provider = 'DiagnosticInfo', icon = '  ',
  161. highlight = 'StatusLineLspDiagnosticsInformation'
  162. }})
  163. table.insert(gls.right, {
  164. DiagnosticHint = {provider = 'DiagnosticHint', icon = '  ',
  165. highlight = 'StatusLineLspDiagnosticsHint'
  166. }
  167. })
  168. table.insert(gls.right, {
  169. TreesitterIcon = {
  170. provider = function()
  171. if next(vim.treesitter.highlighter.active) ~= nil then return ' ' end
  172. return ''
  173. end,
  174. separator = ' ',
  175. separator_highlight = 'StatusLineSeparator',
  176. highlight = 'StatusLineTreeSitter'
  177. }
  178. })
  179. local get_lsp_client = function (msg)
  180. msg = msg or "No Active LSP Client"
  181. local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
  182. local clients = vim.lsp.get_active_clients()
  183. if next(clients) == nil then
  184. return msg
  185. end
  186. local lsps = ""
  187. for _,client in ipairs(clients) do
  188. local filetypes = client.config.filetypes
  189. if filetypes and vim.fn.index(filetypes, buf_ft) ~=1 then
  190. -- print(client.name)
  191. if lsps == "" then
  192. -- print("first", lsps)
  193. lsps = client.name
  194. else
  195. lsps = lsps .. ", " .. client.name
  196. -- print("more", lsps)
  197. end
  198. end
  199. end
  200. if lsps == "" then
  201. return msg
  202. else
  203. return lsps
  204. end
  205. end
  206. table.insert(gls.right, {
  207. ShowLspClient = {
  208. provider = get_lsp_client,
  209. condition = function()
  210. local tbl = {['dashboard'] = true, [' '] = true}
  211. if tbl[vim.bo.filetype] then return false end
  212. return true
  213. end,
  214. icon = ' ',
  215. highlight = 'StatusLineNC'
  216. }
  217. })
  218. table.insert(gls.right, {
  219. LineInfo = {
  220. provider = 'LineColumn',
  221. separator = ' ',
  222. separator_highlight = 'StatusLineSeparator',
  223. highlight = 'StatusLineNC'
  224. }
  225. })
  226. table.insert(gls.right, {
  227. PerCent = {
  228. provider = 'LinePercent',
  229. separator = ' ',
  230. separator_highlight = 'StatusLineSeparator',
  231. highlight = 'StatusLineNC'
  232. }
  233. })
  234. table.insert(gls.right, {
  235. Tabstop = {
  236. provider = function()
  237. return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
  238. end,
  239. condition = condition.hide_in_width,
  240. separator = ' ',
  241. separator_highlight = 'StatusLineSeparator',
  242. highlight = 'StatusLineNC'
  243. }
  244. })
  245. table.insert(gls.right, {
  246. BufferType = {
  247. provider = 'FileTypeName',
  248. condition = condition.hide_in_width,
  249. separator = ' ',
  250. separator_highlight = 'StatusLineSeparator',
  251. highlight = 'StatusLineNC'
  252. }
  253. })
  254. table.insert(gls.right, {
  255. FileEncode = {
  256. provider = 'FileEncode',
  257. condition = condition.hide_in_width,
  258. separator = ' ',
  259. separator_highlight = 'StatusLineSeparator',
  260. highlight = 'StatusLineNC'
  261. }
  262. })
  263. table.insert(gls.right, {
  264. Space = {
  265. provider = function()
  266. return ' '
  267. end,
  268. separator = ' ',
  269. separator_highlight = 'StatusLineSeparator',
  270. highlight = 'StatusLineNC'
  271. }
  272. })
  273. table.insert(gls.short_line_left, {
  274. BufferType = {
  275. provider = 'FileTypeName',
  276. separator = ' ',
  277. separator_highlight = 'StatusLineSeparator',
  278. highlight = 'StatusLineNC'
  279. }
  280. })
  281. table.insert(gls.short_line_left, {
  282. SFileName = {provider = 'SFileName', condition = condition.buffer_not_empty,
  283. highlight = 'StatusLineNC'
  284. }
  285. })
  286. --table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})