123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- -- if not package.loaded['galaxyline'] then
- -- return
- -- end
- local status_ok, gl = pcall(require, "galaxyline")
- if not status_ok then
- return
- end
- -- get my theme in galaxyline repo
- -- local colors = require('galaxyline.theme').default
- local colors = {
- bg = "#2E2E2E",
- -- bg = '#292D38',
- yellow = "#DCDCAA",
- dark_yellow = "#D7BA7D",
- cyan = "#4EC9B0",
- green = "#608B4E",
- light_green = "#B5CEA8",
- string_orange = "#CE9178",
- orange = "#FF8800",
- purple = "#C586C0",
- magenta = "#D16D9E",
- grey = "#858585",
- blue = "#569CD6",
- vivid_blue = "#4FC1FF",
- light_blue = "#9CDCFE",
- red = "#D16969",
- error_red = "#F44747",
- info_yellow = "#FFCC66",
- }
- local condition = require "galaxyline.condition"
- local gls = gl.section
- gl.short_line_list = { "NvimTree", "vista", "dbui", "packer" }
- table.insert(gls.left, {
- ViMode = {
- provider = function()
- -- auto change color according the vim mode
- local mode_color = {
- n = colors.blue,
- i = colors.green,
- v = colors.purple,
- [""] = colors.purple,
- V = colors.purple,
- c = colors.magenta,
- no = colors.blue,
- s = colors.orange,
- S = colors.orange,
- [""] = colors.orange,
- ic = colors.yellow,
- R = colors.red,
- Rv = colors.red,
- cv = colors.blue,
- ce = colors.blue,
- r = colors.cyan,
- rm = colors.cyan,
- ["r?"] = colors.cyan,
- ["!"] = colors.blue,
- t = colors.blue,
- }
- vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim.fn.mode()])
- return "▊"
- end,
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- -- print(vim.fn.getbufvar(0, 'ts'))
- vim.fn.getbufvar(0, "ts")
- table.insert(gls.left, {
- GitIcon = {
- provider = function()
- return " "
- end,
- condition = condition.check_git_workspace,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineGit",
- },
- })
- table.insert(gls.left, {
- GitBranch = {
- provider = "GitBranch",
- condition = condition.check_git_workspace,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.left, {
- DiffAdd = {
- provider = "DiffAdd",
- condition = condition.hide_in_width,
- icon = " ",
- highlight = "StatusLineGitAdd",
- },
- })
- table.insert(gls.left, {
- DiffModified = {
- provider = "DiffModified",
- condition = condition.hide_in_width,
- icon = " 柳",
- highlight = "StatusLineGitChange",
- },
- })
- table.insert(gls.left, {
- DiffRemove = {
- provider = "DiffRemove",
- condition = condition.hide_in_width,
- icon = " ",
- highlight = "StatusLineGitDelete",
- },
- })
- table.insert(gls.left, {
- Filler = {
- provider = function()
- return " "
- end,
- highlight = "StatusLineGitDelete",
- },
- })
- -- get output from shell command
- function os.capture(cmd, raw)
- local f = assert(io.popen(cmd, 'r'))
- local s = assert(f:read('*a'))
- f:close()
- if raw then return s end
- s = string.gsub(s, '^%s+', '')
- s = string.gsub(s, '%s+$', '')
- s = string.gsub(s, '[\n\r]+', ' ')
- return s
- end
- -- cleanup virtual env
- function env_cleanup(venv)
- if string.find(venv, "/") then
- final_venv = venv
- for w in venv:gmatch("([^/]+)") do final_venv=w end
- venv = final_venv
- end
- return venv
- end
- local PythonEnv = function ()
- if vim.bo.filetype == 'python' then
- venv = os.getenv('CONDA_DEFAULT_ENV')
- if venv ~= nil then
- return "🅒 " .. env_cleanup(venv)
- end
- venv = os.getenv('VIRTUAL_ENV')
- if venv ~= nil then
- return "🐍 " .. env_cleanup(venv)
- end
- return ''
- end
- return ''
- end
- table.insert(gls.left, {
- VirtualEnv = {
- provider = PythonEnv,
- highlight = {colors.green, colors.bg},
- event = 'BufEnter'
- }
- })
- table.insert(gls.right, {
- DiagnosticError = {
- provider = "DiagnosticError",
- icon = " ",
- highlight = "StatusLineLspDiagnosticsError",
- },
- })
- table.insert(gls.right, {
- DiagnosticWarn = {
- provider = "DiagnosticWarn",
- icon = " ",
- highlight = "StatusLineLspDiagnosticsWarning",
- },
- })
- table.insert(gls.right, {
- DiagnosticInfo = {
- provider = "DiagnosticInfo",
- icon = " ",
- highlight = "StatusLineLspDiagnosticsInformation",
- },
- })
- table.insert(gls.right, {
- DiagnosticHint = {
- provider = "DiagnosticHint",
- icon = " ",
- highlight = "StatusLineLspDiagnosticsHint",
- },
- })
- table.insert(gls.right, {
- TreesitterIcon = {
- provider = function()
- if next(vim.treesitter.highlighter.active) ~= nil then
- return " "
- end
- return ""
- end,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineTreeSitter",
- },
- })
- local get_lsp_client = function(msg)
- msg = msg or "LSP Inactive"
- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
- local clients = vim.lsp.get_active_clients()
- if next(clients) == nil then
- return msg
- end
- local lsps = ""
- for _, client in ipairs(clients) do
- local filetypes = client.config.filetypes
- if filetypes and vim.fn.index(filetypes, buf_ft) ~= 1 then
- -- print(client.name)
- if lsps == "" then
- -- print("first", lsps)
- lsps = client.name
- else
- lsps = lsps .. ", " .. client.name
- -- print("more", lsps)
- end
- end
- end
- if lsps == "" then
- return msg
- else
- return lsps
- end
- end
- table.insert(gls.right, {
- ShowLspClient = {
- provider = get_lsp_client,
- condition = function()
- local tbl = { ["dashboard"] = true, [" "] = true }
- if tbl[vim.bo.filetype] then
- return false
- end
- return true
- end,
- icon = " ",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.right, {
- LineInfo = {
- provider = "LineColumn",
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.right, {
- PerCent = {
- provider = "LinePercent",
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.right, {
- Tabstop = {
- provider = function()
- return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
- end,
- condition = condition.hide_in_width,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.right, {
- BufferType = {
- provider = "FileTypeName",
- condition = condition.hide_in_width,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.right, {
- FileEncode = {
- provider = "FileEncode",
- condition = condition.hide_in_width,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.right, {
- Space = {
- provider = function()
- return " "
- end,
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.short_line_left, {
- BufferType = {
- provider = "FileTypeName",
- separator = " ",
- separator_highlight = "StatusLineSeparator",
- highlight = "StatusLineNC",
- },
- })
- table.insert(gls.short_line_left, {
- SFileName = {
- provider = "SFileName",
- condition = condition.buffer_not_empty,
- highlight = "StatusLineNC",
- },
- })
- --table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})
|