2021-08-19 05:06:49 -04:00
|
|
|
local global_theme = "themes/" .. require("utils").load_config().ui.theme
|
2021-08-19 02:29:42 -04:00
|
|
|
local colors = require(global_theme)
|
|
|
|
|
2021-07-17 07:14:52 -04:00
|
|
|
local present1, gl = pcall(require, "galaxyline")
|
|
|
|
local present2, condition = pcall(require, "galaxyline.condition")
|
|
|
|
if not (present1 or present2) then
|
2021-08-16 03:49:09 -04:00
|
|
|
return
|
2021-07-15 11:43:17 -04:00
|
|
|
end
|
2021-07-08 23:44:04 -04:00
|
|
|
|
2021-07-15 11:43:17 -04:00
|
|
|
local gls = gl.section
|
|
|
|
|
2021-08-16 03:49:09 -04:00
|
|
|
gl.short_line_list = { " " }
|
2021-07-15 11:43:17 -04:00
|
|
|
|
2021-08-19 02:29:42 -04:00
|
|
|
local icon_styles = {
|
|
|
|
default = {
|
|
|
|
left = "",
|
|
|
|
right = " ",
|
|
|
|
main_icon = " ",
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
position_icon = " ",
|
|
|
|
},
|
2021-08-13 02:42:43 -04:00
|
|
|
|
2021-08-19 02:29:42 -04:00
|
|
|
round = {
|
|
|
|
left = "",
|
|
|
|
right = "",
|
|
|
|
main_icon = " ",
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
position_icon = " ",
|
|
|
|
},
|
|
|
|
|
|
|
|
slant = {
|
|
|
|
left = " ",
|
2021-08-19 08:05:24 -04:00
|
|
|
right = " ",
|
2021-08-19 02:29:42 -04:00
|
|
|
main_icon = " ",
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
position_icon = " ",
|
|
|
|
},
|
|
|
|
|
|
|
|
block = {
|
|
|
|
left = " ",
|
|
|
|
right = " ",
|
|
|
|
main_icon = " ",
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
position_icon = " ",
|
|
|
|
},
|
2021-08-19 08:05:24 -04:00
|
|
|
|
|
|
|
arrow = {
|
|
|
|
left = "",
|
|
|
|
right = "",
|
|
|
|
main_icon = " ",
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
position_icon = " ",
|
|
|
|
},
|
2021-08-19 02:29:42 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 05:06:49 -04:00
|
|
|
local user_statusline_style = require("utils").load_config().ui.statusline_style
|
2021-08-19 02:29:42 -04:00
|
|
|
local statusline_style = icon_styles[user_statusline_style]
|
|
|
|
|
|
|
|
local left_separator = statusline_style.left
|
|
|
|
local right_separator = statusline_style.right
|
2021-07-15 11:43:17 -04:00
|
|
|
|
|
|
|
gls.left[1] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
FirstElement = {
|
|
|
|
provider = function()
|
|
|
|
return "▋"
|
|
|
|
end,
|
|
|
|
highlight = { colors.nord_blue, colors.nord_blue },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gls.left[2] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
statusIcon = {
|
|
|
|
provider = function()
|
2021-08-19 02:29:42 -04:00
|
|
|
return statusline_style.main_icon
|
2021-08-16 03:49:09 -04:00
|
|
|
end,
|
|
|
|
highlight = { colors.statusline_bg, colors.nord_blue },
|
2021-08-19 08:05:24 -04:00
|
|
|
separator = right_separator,
|
|
|
|
separator_highlight = { colors.nord_blue, colors.one_bg2 },
|
2021-08-16 03:49:09 -04:00
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gls.left[3] = {
|
2021-08-19 08:05:24 -04:00
|
|
|
left_arow2 = {
|
|
|
|
provider = function() end,
|
|
|
|
separator = right_separator .. " ",
|
|
|
|
separator_highlight = { colors.one_bg2, colors.lightbg },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
gls.left[4] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
FileIcon = {
|
|
|
|
provider = "FileIcon",
|
|
|
|
condition = condition.buffer_not_empty,
|
|
|
|
highlight = { colors.white, colors.lightbg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[5] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
FileName = {
|
|
|
|
provider = function()
|
|
|
|
local fileinfo = require "galaxyline.provider_fileinfo"
|
|
|
|
return fileinfo.get_current_file_name("", "")
|
|
|
|
end,
|
|
|
|
condition = condition.buffer_not_empty,
|
|
|
|
highlight = { colors.white, colors.lightbg },
|
|
|
|
separator = right_separator,
|
|
|
|
separator_highlight = { colors.lightbg, colors.lightbg2 },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[6] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
current_dir = {
|
|
|
|
provider = function()
|
|
|
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
|
|
|
return " " .. dir_name .. " "
|
|
|
|
end,
|
|
|
|
highlight = { colors.grey_fg2, colors.lightbg2 },
|
|
|
|
separator = right_separator,
|
|
|
|
separator_highlight = { colors.lightbg2, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
local checkwidth = function()
|
2021-08-16 03:49:09 -04:00
|
|
|
local squeeze_width = vim.fn.winwidth(0) / 2
|
|
|
|
if squeeze_width > 30 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
2021-07-08 23:44:04 -04:00
|
|
|
end
|
2021-07-15 11:43:17 -04:00
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[7] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
DiffAdd = {
|
|
|
|
provider = "DiffAdd",
|
|
|
|
condition = checkwidth,
|
|
|
|
icon = " ",
|
|
|
|
highlight = { colors.white, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[8] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
DiffModified = {
|
|
|
|
provider = "DiffModified",
|
|
|
|
condition = checkwidth,
|
|
|
|
icon = " ",
|
|
|
|
highlight = { colors.grey_fg2, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[9] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
DiffRemove = {
|
|
|
|
provider = "DiffRemove",
|
|
|
|
condition = checkwidth,
|
|
|
|
icon = " ",
|
|
|
|
highlight = { colors.grey_fg2, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[10] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
DiagnosticError = {
|
|
|
|
provider = "DiagnosticError",
|
|
|
|
icon = " ",
|
|
|
|
highlight = { colors.red, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.left[11] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
DiagnosticWarn = {
|
|
|
|
provider = "DiagnosticWarn",
|
|
|
|
icon = " ",
|
|
|
|
highlight = { colors.yellow, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gls.right[1] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
lsp_status = {
|
|
|
|
provider = function()
|
|
|
|
local clients = vim.lsp.get_active_clients()
|
|
|
|
if next(clients) ~= nil then
|
|
|
|
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
|
|
|
for _, client in ipairs(clients) do
|
|
|
|
local filetypes = client.config.filetypes
|
|
|
|
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
|
|
|
return " " .. " " .. " LSP"
|
|
|
|
end
|
2021-07-15 11:43:17 -04:00
|
|
|
end
|
2021-08-16 03:49:09 -04:00
|
|
|
return ""
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
highlight = { colors.grey_fg2, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gls.right[2] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
GitIcon = {
|
|
|
|
provider = function()
|
|
|
|
return " "
|
|
|
|
end,
|
|
|
|
condition = require("galaxyline.condition").check_git_workspace,
|
|
|
|
highlight = { colors.grey_fg2, colors.statusline_bg },
|
|
|
|
separator = " ",
|
|
|
|
separator_highlight = { colors.statusline_bg, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gls.right[3] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
GitBranch = {
|
|
|
|
provider = "GitBranch",
|
|
|
|
condition = require("galaxyline.condition").check_git_workspace,
|
|
|
|
highlight = { colors.grey_fg2, colors.statusline_bg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-14 13:05:10 -04:00
|
|
|
local mode_colors = {
|
2021-08-16 03:49:09 -04:00
|
|
|
[110] = { "NORMAL", colors.red },
|
|
|
|
[105] = { "INSERT", colors.dark_purple },
|
|
|
|
[99] = { "COMMAND", colors.pink },
|
|
|
|
[116] = { "TERMINAL", colors.green },
|
|
|
|
[118] = { "VISUAL", colors.cyan },
|
|
|
|
[22] = { "V-BLOCK", colors.cyan },
|
|
|
|
[86] = { "V_LINE", colors.cyan },
|
|
|
|
[82] = { "REPLACE", colors.orange },
|
|
|
|
[115] = { "SELECT", colors.nord_blue },
|
|
|
|
[83] = { "S-LINE", colors.nord_blue },
|
2021-08-14 13:05:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
local mode = function(n)
|
2021-08-16 03:49:09 -04:00
|
|
|
return mode_colors[vim.fn.mode():byte()][n]
|
2021-08-13 02:42:43 -04:00
|
|
|
end
|
|
|
|
|
2021-07-15 11:43:17 -04:00
|
|
|
gls.right[4] = {
|
2021-08-19 08:05:24 -04:00
|
|
|
left_arrow = {
|
|
|
|
provider = function() end,
|
|
|
|
separator = " " .. left_separator,
|
|
|
|
separator_highlight = { colors.one_bg2, colors.statusline_bg },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
gls.right[5] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
left_round = {
|
|
|
|
provider = function()
|
|
|
|
vim.cmd("hi Galaxyleft_round guifg=" .. mode(2))
|
|
|
|
return left_separator
|
|
|
|
end,
|
2021-08-19 08:05:24 -04:00
|
|
|
highlight = { "GalaxyViMode", colors.one_bg2 },
|
2021-08-16 03:49:09 -04:00
|
|
|
},
|
2021-08-13 02:42:43 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.right[6] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
viMode_icon = {
|
|
|
|
provider = function()
|
|
|
|
vim.cmd("hi GalaxyviMode_icon guibg=" .. mode(2))
|
2021-08-19 02:29:42 -04:00
|
|
|
return statusline_style.vi_mode_icon
|
2021-08-16 03:49:09 -04:00
|
|
|
end,
|
|
|
|
highlight = { colors.statusline_bg, colors.red },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.right[7] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
ViMode = {
|
|
|
|
provider = function()
|
|
|
|
vim.cmd("hi GalaxyViMode guifg=" .. mode(2))
|
|
|
|
return " " .. mode(1) .. " "
|
|
|
|
end,
|
|
|
|
highlight = { "GalaxyViMode", colors.lightbg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.right[8] = {
|
|
|
|
left_arrow2 = {
|
|
|
|
provider = function() end,
|
|
|
|
separator = left_separator,
|
|
|
|
separator_highlight = { colors.grey, colors.lightbg },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
gls.right[9] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
some_RoundIcon = {
|
|
|
|
provider = function()
|
2021-08-19 02:29:42 -04:00
|
|
|
return statusline_style.position_icon
|
2021-08-16 03:49:09 -04:00
|
|
|
end,
|
|
|
|
separator = left_separator,
|
2021-08-19 08:05:24 -04:00
|
|
|
separator_highlight = { colors.green, colors.grey },
|
2021-08-16 03:49:09 -04:00
|
|
|
highlight = { colors.lightbg, colors.green },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|
|
|
|
|
2021-08-19 08:05:24 -04:00
|
|
|
gls.right[10] = {
|
2021-08-16 03:49:09 -04:00
|
|
|
line_percentage = {
|
|
|
|
provider = function()
|
|
|
|
local current_line = vim.fn.line "."
|
|
|
|
local total_line = vim.fn.line "$"
|
|
|
|
|
|
|
|
if current_line == 1 then
|
|
|
|
return " Top "
|
|
|
|
elseif current_line == vim.fn.line "$" then
|
|
|
|
return " Bot "
|
|
|
|
end
|
|
|
|
local result, _ = math.modf((current_line / total_line) * 100)
|
|
|
|
return " " .. result .. "% "
|
|
|
|
end,
|
|
|
|
highlight = { colors.green, colors.lightbg },
|
|
|
|
},
|
2021-07-15 11:43:17 -04:00
|
|
|
}
|