init.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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 = "StatusLineNC",
  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 = {
  154. provider = "DiagnosticError",
  155. icon = "  ",
  156. highlight = "StatusLineLspDiagnosticsError",
  157. },
  158. })
  159. table.insert(gls.right, {
  160. DiagnosticWarn = {
  161. provider = "DiagnosticWarn",
  162. icon = "  ",
  163. highlight = "StatusLineLspDiagnosticsWarning",
  164. },
  165. })
  166. table.insert(gls.right, {
  167. DiagnosticInfo = {
  168. provider = "DiagnosticInfo",
  169. icon = "  ",
  170. highlight = "StatusLineLspDiagnosticsInformation",
  171. },
  172. })
  173. table.insert(gls.right, {
  174. DiagnosticHint = {
  175. provider = "DiagnosticHint",
  176. icon = "  ",
  177. highlight = "StatusLineLspDiagnosticsHint",
  178. },
  179. })
  180. table.insert(gls.right, {
  181. TreesitterIcon = {
  182. provider = function()
  183. if next(vim.treesitter.highlighter.active) ~= nil then
  184. return " "
  185. end
  186. return ""
  187. end,
  188. separator = " ",
  189. separator_highlight = "StatusLineSeparator",
  190. highlight = "StatusLineTreeSitter",
  191. },
  192. })
  193. local get_lsp_client = function(msg)
  194. msg = msg or "No Active LSP Client"
  195. local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
  196. local clients = vim.lsp.get_active_clients()
  197. if next(clients) == nil then
  198. return msg
  199. end
  200. local lsps = ""
  201. for _, client in ipairs(clients) do
  202. local filetypes = client.config.filetypes
  203. if filetypes and vim.fn.index(filetypes, buf_ft) ~= 1 then
  204. -- print(client.name)
  205. if lsps == "" then
  206. -- print("first", lsps)
  207. lsps = client.name
  208. else
  209. lsps = lsps .. ", " .. client.name
  210. -- print("more", lsps)
  211. end
  212. end
  213. end
  214. if lsps == "" then
  215. return msg
  216. else
  217. return lsps
  218. end
  219. end
  220. table.insert(gls.right, {
  221. ShowLspClient = {
  222. provider = get_lsp_client,
  223. condition = function()
  224. local tbl = { ["dashboard"] = true, [" "] = true }
  225. if tbl[vim.bo.filetype] then
  226. return false
  227. end
  228. return true
  229. end,
  230. icon = " ",
  231. highlight = "StatusLineNC",
  232. },
  233. })
  234. table.insert(gls.right, {
  235. LineInfo = {
  236. provider = "LineColumn",
  237. separator = " ",
  238. separator_highlight = "StatusLineSeparator",
  239. highlight = "StatusLineNC",
  240. },
  241. })
  242. table.insert(gls.right, {
  243. PerCent = {
  244. provider = "LinePercent",
  245. separator = " ",
  246. separator_highlight = "StatusLineSeparator",
  247. highlight = "StatusLineNC",
  248. },
  249. })
  250. table.insert(gls.right, {
  251. Tabstop = {
  252. provider = function()
  253. return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
  254. end,
  255. condition = condition.hide_in_width,
  256. separator = " ",
  257. separator_highlight = "StatusLineSeparator",
  258. highlight = "StatusLineNC",
  259. },
  260. })
  261. table.insert(gls.right, {
  262. BufferType = {
  263. provider = "FileTypeName",
  264. condition = condition.hide_in_width,
  265. separator = " ",
  266. separator_highlight = "StatusLineSeparator",
  267. highlight = "StatusLineNC",
  268. },
  269. })
  270. table.insert(gls.right, {
  271. FileEncode = {
  272. provider = "FileEncode",
  273. condition = condition.hide_in_width,
  274. separator = " ",
  275. separator_highlight = "StatusLineSeparator",
  276. highlight = "StatusLineNC",
  277. },
  278. })
  279. table.insert(gls.right, {
  280. Space = {
  281. provider = function()
  282. return " "
  283. end,
  284. separator = " ",
  285. separator_highlight = "StatusLineSeparator",
  286. highlight = "StatusLineNC",
  287. },
  288. })
  289. table.insert(gls.short_line_left, {
  290. BufferType = {
  291. provider = "FileTypeName",
  292. separator = " ",
  293. separator_highlight = "StatusLineSeparator",
  294. highlight = "StatusLineNC",
  295. },
  296. })
  297. table.insert(gls.short_line_left, {
  298. SFileName = {
  299. provider = "SFileName",
  300. condition = condition.buffer_not_empty,
  301. highlight = "StatusLineNC",
  302. },
  303. })
  304. --table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})