init.lua 6.3 KB

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