2021-07-13 03:59:16 +02:00
|
|
|
|
-- if not package.loaded['galaxyline'] then
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
|
|
|
|
local status_ok, gl = pcall(require, "galaxyline")
|
|
|
|
|
if not status_ok then
|
|
|
|
|
return
|
2021-07-13 03:11:43 +02:00
|
|
|
|
end
|
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
-- NOTE: if someone defines colors but doesn't have them then this will break
|
2021-07-25 03:17:11 +02:00
|
|
|
|
local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette")
|
2021-07-13 03:59:16 +02:00
|
|
|
|
if not palette_status_ok then
|
2021-07-25 03:17:11 +02:00
|
|
|
|
colors = lvim.builtin.galaxyline.colors
|
2021-07-13 03:59:16 +02:00
|
|
|
|
end
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
local condition = require "galaxyline.condition"
|
|
|
|
|
local gls = gl.section
|
|
|
|
|
gl.short_line_list = { "NvimTree", "vista", "dbui", "packer" }
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
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 = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
-- print(vim.fn.getbufvar(0, 'ts'))
|
|
|
|
|
vim.fn.getbufvar(0, "ts")
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
GitIcon = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return " "
|
|
|
|
|
end,
|
|
|
|
|
condition = condition.check_git_workspace,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.orange, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
GitBranch = {
|
|
|
|
|
provider = "GitBranch",
|
|
|
|
|
condition = condition.check_git_workspace,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
DiffAdd = {
|
|
|
|
|
provider = "DiffAdd",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.green, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
DiffModified = {
|
|
|
|
|
provider = "DiffModified",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
icon = " 柳",
|
|
|
|
|
highlight = { colors.blue, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
DiffRemove = {
|
|
|
|
|
provider = "DiffRemove",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.red, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
Filler = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return " "
|
|
|
|
|
end,
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
-- 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
|
2021-07-13 03:11:43 +02:00
|
|
|
|
return s
|
|
|
|
|
end
|
2021-07-13 03:59:16 +02:00
|
|
|
|
s = string.gsub(s, "^%s+", "")
|
|
|
|
|
s = string.gsub(s, "%s+$", "")
|
|
|
|
|
s = string.gsub(s, "[\n\r]+", " ")
|
|
|
|
|
return s
|
|
|
|
|
end
|
|
|
|
|
-- cleanup virtual env
|
|
|
|
|
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-13 03:11:43 +02:00
|
|
|
|
end
|
2021-07-13 03:59:16 +02:00
|
|
|
|
venv = final_venv
|
2021-07-13 03:11:43 +02:00
|
|
|
|
end
|
2021-07-13 03:59:16 +02:00
|
|
|
|
return venv
|
|
|
|
|
end
|
|
|
|
|
local PythonEnv = function()
|
|
|
|
|
if vim.bo.filetype == "python" then
|
|
|
|
|
local 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) .. ")"
|
2021-07-13 03:11:43 +02:00
|
|
|
|
end
|
|
|
|
|
return ""
|
|
|
|
|
end
|
2021-07-13 03:59:16 +02:00
|
|
|
|
return ""
|
|
|
|
|
end
|
|
|
|
|
table.insert(gls.left, {
|
|
|
|
|
VirtualEnv = {
|
|
|
|
|
provider = PythonEnv,
|
|
|
|
|
event = "BufEnter",
|
|
|
|
|
highlight = { colors.green, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
DiagnosticError = {
|
|
|
|
|
provider = "DiagnosticError",
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.red, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
DiagnosticWarn = {
|
|
|
|
|
provider = "DiagnosticWarn",
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.orange, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
DiagnosticInfo = {
|
|
|
|
|
provider = "DiagnosticInfo",
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.yellow, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
DiagnosticHint = {
|
|
|
|
|
provider = "DiagnosticHint",
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.blue, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
TreesitterIcon = {
|
|
|
|
|
provider = function()
|
|
|
|
|
if next(vim.treesitter.highlighter.active) ~= nil then
|
|
|
|
|
return " "
|
|
|
|
|
end
|
|
|
|
|
return ""
|
|
|
|
|
end,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.green, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-28 03:04:51 +02:00
|
|
|
|
local function get_attached_provider_name(msg)
|
2021-07-13 03:59:16 +02:00
|
|
|
|
msg = msg or "LSP Inactive"
|
2021-07-28 03:04:51 +02:00
|
|
|
|
local buf_clients = vim.lsp.buf_get_clients()
|
|
|
|
|
if next(buf_clients) == nil then
|
2021-07-13 03:59:16 +02:00
|
|
|
|
return msg
|
|
|
|
|
end
|
2021-07-31 06:06:08 +02:00
|
|
|
|
local buf_ft = vim.bo.filetype
|
2021-07-28 03:04:51 +02:00
|
|
|
|
local buf_client_names = {}
|
2021-07-31 06:06:08 +02:00
|
|
|
|
local null_ls_providers = require("lsp.null-ls").requested_providers
|
2021-07-28 03:04:51 +02:00
|
|
|
|
for _, client in pairs(buf_clients) do
|
|
|
|
|
if client.name == "null-ls" then
|
2021-07-31 06:06:08 +02:00
|
|
|
|
for _, provider in pairs(null_ls_providers) do
|
|
|
|
|
if vim.tbl_contains(provider.filetypes, buf_ft) then
|
|
|
|
|
if not vim.tbl_contains(buf_client_names, provider.name) then
|
|
|
|
|
table.insert(buf_client_names, provider.name)
|
|
|
|
|
end
|
2021-07-30 20:44:25 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-07-28 03:04:51 +02:00
|
|
|
|
else
|
|
|
|
|
table.insert(buf_client_names, client.name)
|
2021-07-13 03:11:43 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-07-28 03:04:51 +02:00
|
|
|
|
return table.concat(buf_client_names, ", ")
|
2021-07-13 03:59:16 +02:00
|
|
|
|
end
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
ShowLspClient = {
|
2021-07-28 03:04:51 +02:00
|
|
|
|
provider = get_attached_provider_name,
|
2021-07-13 03:59:16 +02:00
|
|
|
|
condition = function()
|
|
|
|
|
local tbl = { ["dashboard"] = true, [" "] = true }
|
|
|
|
|
if tbl[vim.bo.filetype] then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end,
|
|
|
|
|
icon = " ",
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
LineInfo = {
|
|
|
|
|
provider = "LineColumn",
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
PerCent = {
|
|
|
|
|
provider = "LinePercent",
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
Tabstop = {
|
|
|
|
|
provider = function()
|
2021-07-25 18:36:53 +02:00
|
|
|
|
local label = "Spaces: "
|
|
|
|
|
if not vim.api.nvim_buf_get_option(0, "expandtab") then
|
|
|
|
|
label = "Tab size: "
|
|
|
|
|
end
|
|
|
|
|
return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
|
2021-07-13 03:59:16 +02:00
|
|
|
|
end,
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
BufferType = {
|
|
|
|
|
provider = "FileTypeName",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
2021-07-20 04:50:07 +02:00
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
2021-07-13 03:59:16 +02:00
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
FileEncode = {
|
|
|
|
|
provider = "FileEncode",
|
|
|
|
|
condition = condition.hide_in_width,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.right, {
|
|
|
|
|
Space = {
|
|
|
|
|
provider = function()
|
|
|
|
|
return " "
|
|
|
|
|
end,
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
|
|
|
|
highlight = { colors.grey, colors.alt_bg },
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.short_line_left, {
|
|
|
|
|
BufferType = {
|
|
|
|
|
provider = "FileTypeName",
|
|
|
|
|
separator = " ",
|
|
|
|
|
separator_highlight = { "NONE", colors.alt_bg },
|
2021-07-16 02:49:33 +02:00
|
|
|
|
highlight = { colors.alt_bg, colors.alt_bg },
|
2021-07-13 03:59:16 +02:00
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
table.insert(gls.short_line_left, {
|
|
|
|
|
SFileName = {
|
|
|
|
|
provider = "SFileName",
|
|
|
|
|
condition = condition.buffer_not_empty,
|
2021-07-16 02:49:33 +02:00
|
|
|
|
highlight = { colors.alt_bg, colors.alt_bg },
|
2021-07-13 03:59:16 +02:00
|
|
|
|
},
|
|
|
|
|
})
|
2021-07-13 03:11:43 +02:00
|
|
|
|
|
2021-07-13 03:59:16 +02:00
|
|
|
|
--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.alt_bg}}})
|