2021-07-04 18:40:40 +02:00
|
|
|
|
-- if not package.loaded['galaxyline'] then
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
2021-07-07 02:42:29 +02:00
|
|
|
|
local status_ok, gl = pcall(require, "galaxyline")
|
|
|
|
|
if not status_ok then
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-03-18 07:08:38 +01:00
|
|
|
|
-- get my theme in galaxyline repo
|
2021-07-10 03:01:23 +02:00
|
|
|
|
local colors = O.plugin.galaxyline.colors
|
2021-06-28 15:04:44 +02:00
|
|
|
|
|
2021-07-05 03:14:01 +02:00
|
|
|
|
local condition = require "galaxyline.condition"
|
2020-10-29 02:59:10 +01:00
|
|
|
|
local gls = gl.section
|
2021-07-05 03:14:01 +02:00
|
|
|
|
gl.short_line_list = { "NvimTree", "vista", "dbui", "packer" }
|
2020-10-29 02:59:10 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
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,
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { "NONE", colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-07-03 17:31:55 +02:00
|
|
|
|
-- print(vim.fn.getbufvar(0, 'ts'))
|
2021-07-05 03:14:01 +02:00
|
|
|
|
vim.fn.getbufvar(0, "ts")
|
2020-10-29 02:59:10 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
GitIcon = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return " "
|
|
|
|
|
end,
|
|
|
|
|
condition = condition.check_git_workspace,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.orange, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2020-10-29 02:59:10 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
GitBranch = {
|
|
|
|
|
provider = "GitBranch",
|
|
|
|
|
condition = condition.check_git_workspace,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
DiffAdd = {
|
|
|
|
|
provider = "DiffAdd",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.green, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-06-26 19:48:06 +02:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
DiffModified = {
|
|
|
|
|
provider = "DiffModified",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
icon = " 柳",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.blue, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-06-26 19:48:06 +02:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
DiffRemove = {
|
|
|
|
|
provider = "DiffRemove",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.red, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-07-06 18:12:24 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
Filler = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return " "
|
|
|
|
|
end,
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-06 18:12:24 +02:00
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-07 21:30:55 +02:00
|
|
|
|
-- get output from shell command
|
|
|
|
|
function os.capture(cmd, raw)
|
2021-07-08 03:57:36 +02:00
|
|
|
|
local f = assert(io.popen(cmd, "r"))
|
|
|
|
|
local s = assert(f:read "*a")
|
2021-07-07 21:30:55 +02:00
|
|
|
|
f:close()
|
2021-07-08 03:57:36 +02:00
|
|
|
|
if raw then
|
|
|
|
|
return s
|
|
|
|
|
end
|
|
|
|
|
s = string.gsub(s, "^%s+", "")
|
|
|
|
|
s = string.gsub(s, "%s+$", "")
|
|
|
|
|
s = string.gsub(s, "[\n\r]+", " ")
|
2021-07-07 21:30:55 +02:00
|
|
|
|
return s
|
|
|
|
|
end
|
|
|
|
|
-- cleanup virtual env
|
2021-07-08 03:57:36 +02:00
|
|
|
|
local function env_cleanup(venv)
|
|
|
|
|
if string.find(venv, "/") then
|
|
|
|
|
local final_venv = venv
|
|
|
|
|
for w in venv:gmatch "([^/]+)" do
|
|
|
|
|
final_venv = w
|
2021-07-07 21:30:55 +02:00
|
|
|
|
end
|
2021-07-08 03:57:36 +02:00
|
|
|
|
venv = final_venv
|
|
|
|
|
end
|
|
|
|
|
return venv
|
2021-07-07 21:30:55 +02:00
|
|
|
|
end
|
2021-07-08 03:57:36 +02:00
|
|
|
|
local PythonEnv = function()
|
|
|
|
|
if vim.bo.filetype == "python" then
|
|
|
|
|
local venv = os.getenv "CONDA_DEFAULT_ENV"
|
2021-07-07 21:30:55 +02:00
|
|
|
|
if venv ~= nil then
|
2021-07-10 19:40:40 +02:00
|
|
|
|
return " (" .. env_cleanup(venv) .. ")"
|
2021-07-07 21:30:55 +02:00
|
|
|
|
end
|
2021-07-08 03:57:36 +02:00
|
|
|
|
venv = os.getenv "VIRTUAL_ENV"
|
2021-07-07 21:30:55 +02:00
|
|
|
|
if venv ~= nil then
|
2021-07-08 03:57:36 +02:00
|
|
|
|
return " (" .. env_cleanup(venv) .. ")"
|
2021-07-07 21:30:55 +02:00
|
|
|
|
end
|
2021-07-08 03:57:36 +02:00
|
|
|
|
return ""
|
2021-07-07 21:30:55 +02:00
|
|
|
|
end
|
2021-07-08 03:57:36 +02:00
|
|
|
|
return ""
|
2021-07-07 21:30:55 +02:00
|
|
|
|
end
|
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
VirtualEnv = {
|
|
|
|
|
provider = PythonEnv,
|
2021-07-08 03:57:36 +02:00
|
|
|
|
event = "BufEnter",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.green, colors.bg },
|
2021-07-08 03:57:36 +02:00
|
|
|
|
},
|
2021-07-07 21:30:55 +02:00
|
|
|
|
})
|
2021-07-06 18:12:24 +02:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
DiagnosticError = {
|
|
|
|
|
provider = "DiagnosticError",
|
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.red, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-07-05 03:14:01 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
DiagnosticWarn = {
|
|
|
|
|
provider = "DiagnosticWarn",
|
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.orange, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
DiagnosticInfo = {
|
|
|
|
|
provider = "DiagnosticInfo",
|
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.yellow, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-04 21:01:09 +02:00
|
|
|
|
|
2021-07-05 03:14:01 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
DiagnosticHint = {
|
|
|
|
|
provider = "DiagnosticHint",
|
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.blue, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-07-04 21:01:09 +02:00
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
TreesitterIcon = {
|
|
|
|
|
provider = function()
|
|
|
|
|
if next(vim.treesitter.highlighter.active) ~= nil then
|
|
|
|
|
return " "
|
|
|
|
|
end
|
|
|
|
|
return ""
|
|
|
|
|
end,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.green, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-05-26 01:09:32 +02:00
|
|
|
|
|
2021-07-05 03:14:01 +02:00
|
|
|
|
local get_lsp_client = function(msg)
|
2021-07-06 18:12:24 +02:00
|
|
|
|
msg = msg or "LSP Inactive"
|
2021-07-05 03:14:01 +02:00
|
|
|
|
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
|
2021-07-03 17:27:00 +02:00
|
|
|
|
end
|
2021-07-05 03:14:01 +02:00
|
|
|
|
end
|
|
|
|
|
if lsps == "" then
|
|
|
|
|
return msg
|
|
|
|
|
else
|
|
|
|
|
return lsps
|
|
|
|
|
end
|
2021-07-03 17:27:00 +02:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
ShowLspClient = {
|
|
|
|
|
provider = get_lsp_client,
|
|
|
|
|
condition = function()
|
|
|
|
|
local tbl = { ["dashboard"] = true, [" "] = true }
|
|
|
|
|
if tbl[vim.bo.filetype] then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end,
|
2021-07-10 19:40:40 +02:00
|
|
|
|
icon = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
LineInfo = {
|
|
|
|
|
provider = "LineColumn",
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2020-10-29 02:59:10 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
PerCent = {
|
|
|
|
|
provider = "LinePercent",
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-22 01:02:49 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
Tabstop = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
|
|
|
|
|
end,
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-22 01:02:49 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
BufferType = {
|
|
|
|
|
provider = "FileTypeName",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-22 01:02:49 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
FileEncode = {
|
|
|
|
|
provider = "FileEncode",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-22 01:02:49 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.right, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
Space = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return " "
|
|
|
|
|
end,
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2020-10-29 02:59:10 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.short_line_left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
BufferType = {
|
|
|
|
|
provider = "FileTypeName",
|
|
|
|
|
separator = " ",
|
2021-07-11 03:09:58 +02:00
|
|
|
|
separator_highlight = { "NONE", colors.bg },
|
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-05-27 06:05:23 +02:00
|
|
|
|
table.insert(gls.short_line_left, {
|
2021-07-05 03:14:01 +02:00
|
|
|
|
SFileName = {
|
|
|
|
|
provider = "SFileName",
|
|
|
|
|
condition = condition.buffer_not_empty,
|
2021-07-11 03:09:58 +02:00
|
|
|
|
highlight = { colors.grey, colors.bg },
|
2021-07-05 03:14:01 +02:00
|
|
|
|
},
|
2021-05-27 06:05:23 +02:00
|
|
|
|
})
|
2021-03-18 07:08:38 +01:00
|
|
|
|
|
2021-05-27 06:09:35 +02:00
|
|
|
|
--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}})
|