dotfiles/nvim/lua/pluginconf/galaxyline.lua

373 lines
8.3 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- BASED OFF https://github.com/LoydAndrew/nvim/blob/main/evilline.lua
local gl = require("galaxyline")
local gls = gl.section
local extension = require("galaxyline.provider_extensions")
gl.short_line_list = {
"LuaTree",
"vista",
"dbui",
"startify",
"term",
"nerdtree",
"fugitive",
"fugitiveblame",
"plug"
}
-- VistaPlugin = extension.vista_nearest
local colors = {
bg = "#44475a",
line_bg = "#282c34",
fg = "#f8f8f2",
fg_green = "#65a380",
yellow = "#f1fa8c",
cyan = "#8be9fd",
darkblue = "#081633",
green = "#50fa7b",
orange = "#ffb86c",
purple = "#bd93f9",
magenta = "#ff79c6",
blue = "#51afef",
red = "#ff5555"
}
local mode_color = {
n = colors.green,
i = colors.blue,
v = colors.magenta,
[""] = colors.blue,
V = colors.blue,
c = colors.red,
no = colors.magenta,
s = colors.orange,
S = colors.orange,
[""] = colors.orange,
ic = colors.yellow,
R = colors.purple,
Rv = colors.purple,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
["r?"] = colors.cyan,
["!"] = colors.green,
t = colors.green,
c = colors.purple,
["r?"] = colors.red,
["r"] = colors.red,
rm = colors.red,
R = colors.yellow,
Rv = colors.magenta
}
local function lsp_status(status)
shorter_stat = ""
for match in string.gmatch(status, "[^%s]+") do
err_warn = string.find(match, "^[WE]%d+", 0)
if not err_warn then
shorter_stat = shorter_stat .. " " .. match
end
end
return shorter_stat
end
local function get_coc_lsp()
local status = vim.fn["coc#status"]()
if not status or status == "" then
return ""
end
return lsp_status(status)
end
function get_diagnostic_info()
if vim.fn.exists("*coc#rpc#start_server") == 1 then
return get_coc_lsp()
end
return ""
end
local function get_current_func()
local has_func, func_name = pcall(vim.fn.nvim_buf_get_var, 0, "coc_current_function")
if not has_func then
return
end
return func_name
end
function get_function_info()
if vim.fn.exists("*coc#rpc#start_server") == 1 then
return get_current_func()
end
return ""
end
local function trailing_whitespace()
local trail = vim.fn.search("\\s$", "nw")
if trail ~= 0 then
return " "
else
return nil
end
end
CocStatus = get_diagnostic_info
CocFunc = get_current_func
TrailingWhiteSpace = trailing_whitespace
function has_file_type()
local f_type = vim.bo.filetype
if not f_type or f_type == "" then
return false
end
return true
end
local buffer_not_empty = function()
if vim.fn.empty(vim.fn.expand("%:t")) ~= 1 then
return true
end
return false
end
gls.left[1] = {
FirstElement = {
provider = function()
return " "
end,
highlight = {colors.blue, colors.line_bg}
}
}
gls.left[2] = {
ViMode = {
provider = function()
-- auto change color according the vim mode
local alias = {
n = "NORMAL",
i = "INSERT",
c = "COMMAND",
V = "VISUAL",
[""] = "VISUAL",
v = "VISUAL",
c = "COMMAND-LINE",
["r?"] = ":CONFIRM",
rm = "--MORE",
R = "REPLACE",
Rv = "VIRTUAL",
s = "SELECT",
S = "SELECT",
["r"] = "HIT-ENTER",
[""] = "SELECT",
t = "TERMINAL",
["!"] = "SHELL"
}
local vim_mode = vim.fn.mode()
vim.api.nvim_command("hi GalaxyViMode guibg=" .. mode_color[vim_mode])
return alias[vim_mode] .. ""
end,
highlight = {colors.line_bg, colors.line_bg, "bold"}
}
}
gls.left[3] = {
ModeSep = {
provider = function()
vim.api.nvim_command("hi GalaxyModeSep guifg=" .. mode_color[vim.fn.mode()] .. " guibg=" .. colors.bg)
return ""
end,
highlight = {colors.line_bg, colors.line_bg},
separator = "",
separator_highlight = {colors.bg, colors.line_bg}
}
}
gls.left[4] = {
FileIcon = {
provider = "FileIcon",
condition = buffer_not_empty,
highlight = {require("galaxyline.provider_fileinfo").get_file_icon_color, colors.line_bg}
}
}
gls.left[5] = {
FileName = {
provider = {"FileName", "FileSize"},
condition = buffer_not_empty,
highlight = {colors.fg, colors.line_bg, "bold"}
}
}
gls.left[6] = {
GitIcon = {
provider = function()
return ""
end,
condition = require("galaxyline.provider_vcs").check_git_workspace,
highlight = {colors.orange, colors.line_bg}
}
}
gls.left[7] = {
GitBranch = {
provider = "GitBranch",
condition = require("galaxyline.provider_vcs").check_git_workspace,
highlight = {"#8FBCBB", colors.line_bg, "bold"}
}
}
local checkwidth = function()
local squeeze_width = vim.fn.winwidth(0) / 2
if squeeze_width > 40 then
return true
end
return false
end
gls.left[8] = {
DiffAdd = {
provider = "DiffAdd",
condition = checkwidth,
icon = "",
highlight = {colors.green, colors.line_bg}
}
}
gls.left[9] = {
DiffModified = {
provider = "DiffModified",
condition = checkwidth,
icon = "",
highlight = {colors.orange, colors.line_bg}
}
}
gls.left[10] = {
DiffRemove = {
provider = "DiffRemove",
condition = checkwidth,
icon = "",
highlight = {colors.red, colors.line_bg}
}
}
gls.left[11] = {
LeftEnd = {
provider = function()
return ""
end,
highlight = {colors.line_bg, colors.bg},
}
}
gls.left[12] = {
TrailingWhiteSpace = {
provider = TrailingWhiteSpace,
icon = "",
highlight = {colors.yellow, colors.bg}
}
}
gls.left[13] = {
DiagnosticError = {
provider = "DiagnosticError",
icon = "",
highlight = {colors.red, colors.bg}
}
}
gls.left[14] = {
Space = {
provider = function()
return " "
end,
highlight = {colors.bg, colors.bg}
}
}
gls.left[15] = {
DiagnosticWarn = {
provider = "DiagnosticWarn",
icon = "",
highlight = {colors.yellow, colors.bg}
}
}
gls.left[16] = {
CocStatus = {
provider = CocStatus,
highlight = {colors.green, colors.bg},
icon = " 🗱"
}
}
gls.left[17] = {
CocFunc = {
provider = CocFunc,
icon = " λ ",
highlight = {colors.yellow, colors.bg}
}
}
gls.right[1] = {
BufferType = {
provider = "FileTypeName",
separator = "",
condition = has_file_type,
separator_highlight = {colors.line_bg, colors.bg},
highlight = {colors.fg, colors.line_bg}
}
}
gls.right[2] = {
TypeSep = {
provider = function()
return ""
end,
highlight = {colors.bg, colors.line_bg}
}
}
gls.right[3] = {
FileFormat = {
provider = "FileFormat",
separator = "",
separator_highlight = {colors.line_bg, colors.bg},
highlight = {colors.fg, colors.line_bg, "bold"}
}
}
gls.right[4] = {
LineInfo = {
provider = "LineColumn",
separator = " |",
separator_highlight = {colors.blue, colors.line_bg},
highlight = {colors.fg, colors.line_bg}
}
}
gls.right[5] = {
PerCent = {
provider = "LinePercent",
highlight = {colors.cyan, colors.darkblue, "bold"}
}
}
gls.right[6] = {
ScrollBar = {
provider = 'ScrollBar',
highlight = {colors.blue,colors.purple},
}
}
gls.short_line_left[1] = {
BufferType = {
provider = "FileTypeName",
separator = "",
condition = has_file_type,
separator_highlight = {colors.purple, colors.bg},
highlight = {colors.fg, colors.purple}
}
}
gls.short_line_right[1] = {
BufferIcon = {
provider = "BufferIcon",
separator = "",
condition = has_file_type,
separator_highlight = {colors.purple, colors.bg},
highlight = {colors.fg, colors.purple}
}
}