2021-08-22 09:49:15 +02:00
|
|
|
|
local colors = require("colors").get()
|
2021-08-26 07:18:13 +02:00
|
|
|
|
local lsp = require "feline.providers.lsp"
|
2021-07-15 17:43:17 +02:00
|
|
|
|
|
2021-08-19 08:29:42 +02:00
|
|
|
|
local icon_styles = {
|
|
|
|
|
default = {
|
|
|
|
|
left = "",
|
|
|
|
|
right = " ",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
2021-08-22 09:49:15 +02:00
|
|
|
|
arrow = {
|
|
|
|
|
left = "",
|
|
|
|
|
right = "",
|
2021-08-19 08:29:42 +02:00
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
block = {
|
|
|
|
|
left = " ",
|
|
|
|
|
right = " ",
|
|
|
|
|
main_icon = " ",
|
2021-08-27 10:18:04 +02:00
|
|
|
|
vi_mode_icon = " ",
|
2021-08-19 08:29:42 +02:00
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
2021-08-19 14:05:24 +02:00
|
|
|
|
|
2021-08-22 09:49:15 +02:00
|
|
|
|
round = {
|
|
|
|
|
left = "",
|
|
|
|
|
right = "",
|
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
slant = {
|
|
|
|
|
left = " ",
|
|
|
|
|
right = " ",
|
2021-08-19 14:05:24 +02:00
|
|
|
|
main_icon = " ",
|
|
|
|
|
vi_mode_icon = " ",
|
|
|
|
|
position_icon = " ",
|
|
|
|
|
},
|
2021-08-19 08:29:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-19 10:11:28 +02:00
|
|
|
|
local user_statusline_style = require("core.utils").load_config().plugins.options.statusline.style
|
2021-08-19 08:29:42 +02:00
|
|
|
|
local statusline_style = icon_styles[user_statusline_style]
|
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
-- Initialize the components table
|
|
|
|
|
local components = {
|
2021-09-07 12:00:34 +02:00
|
|
|
|
active = {},
|
|
|
|
|
inactive = {},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
-- Initialize left, mid and right
|
|
|
|
|
table.insert(components.active, {})
|
|
|
|
|
table.insert(components.active, {})
|
|
|
|
|
table.insert(components.active, {})
|
|
|
|
|
|
|
|
|
|
components.active[1][1] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = statusline_style.main_icon,
|
|
|
|
|
|
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.statusline_bg,
|
|
|
|
|
bg = colors.nord_blue,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-08-26 07:18:13 +02:00
|
|
|
|
|
|
|
|
|
right_sep = { str = statusline_style.right, hl = {
|
|
|
|
|
fg = colors.nord_blue,
|
2021-09-14 06:01:48 +02:00
|
|
|
|
bg = colors.lightbg,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
} },
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[1][2] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = function()
|
|
|
|
|
local filename = vim.fn.expand "%:t"
|
|
|
|
|
local extension = vim.fn.expand "%:e"
|
|
|
|
|
local icon = require("nvim-web-devicons").get_icon(filename, extension)
|
|
|
|
|
if icon == nil then
|
2021-09-14 06:01:48 +02:00
|
|
|
|
icon = " "
|
2021-08-26 07:18:13 +02:00
|
|
|
|
return icon
|
|
|
|
|
end
|
2021-09-14 06:01:48 +02:00
|
|
|
|
return " " .. icon .. " " .. filename .. " "
|
2021-08-26 07:18:13 +02:00
|
|
|
|
end,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 70
|
|
|
|
|
end,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.white,
|
|
|
|
|
bg = colors.lightbg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } },
|
|
|
|
|
}
|
2021-08-19 14:43:58 +02:00
|
|
|
|
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][3] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = function()
|
|
|
|
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
2021-08-28 03:18:51 +02:00
|
|
|
|
return " " .. dir_name .. " "
|
2021-08-26 07:18:13 +02:00
|
|
|
|
end,
|
2021-08-19 14:43:58 +02:00
|
|
|
|
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 80
|
|
|
|
|
end,
|
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.lightbg2,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-09-17 15:06:32 +02:00
|
|
|
|
right_sep = {
|
|
|
|
|
str = statusline_style.right,
|
|
|
|
|
hi = {
|
|
|
|
|
fg = colors.lightbg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][4] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "git_diff_added",
|
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-08-26 07:18:13 +02:00
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
2021-08-26 07:18:13 +02:00
|
|
|
|
-- diffModfified
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][5] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "git_diff_changed",
|
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-08-26 07:18:13 +02:00
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
2021-08-26 07:18:13 +02:00
|
|
|
|
-- diffRemove
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][6] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "git_diff_removed",
|
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-08-26 07:18:13 +02:00
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][7] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "diagnostic_errors",
|
|
|
|
|
enabled = function()
|
|
|
|
|
return lsp.diagnostics_exist "Error"
|
|
|
|
|
end,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = { fg = colors.red },
|
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][8] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "diagnostic_warnings",
|
|
|
|
|
enabled = function()
|
|
|
|
|
return lsp.diagnostics_exist "Warning"
|
|
|
|
|
end,
|
|
|
|
|
hl = { fg = colors.yellow },
|
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][9] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "diagnostic_hints",
|
|
|
|
|
enabled = function()
|
|
|
|
|
return lsp.diagnostics_exist "Hint"
|
|
|
|
|
end,
|
|
|
|
|
hl = { fg = colors.grey_fg2 },
|
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 06:01:48 +02:00
|
|
|
|
components.active[1][10] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = "diagnostic_info",
|
|
|
|
|
enabled = function()
|
|
|
|
|
return lsp.diagnostics_exist "Information"
|
|
|
|
|
end,
|
|
|
|
|
hl = { fg = colors.green },
|
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[2][1] = {
|
2021-08-26 09:52:48 +02:00
|
|
|
|
provider = function()
|
|
|
|
|
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
|
|
|
|
if Lsp then
|
|
|
|
|
local msg = Lsp.message or ""
|
|
|
|
|
local percentage = Lsp.percentage or 0
|
|
|
|
|
local title = Lsp.title or ""
|
|
|
|
|
local spinners = {
|
2021-08-27 06:28:54 +02:00
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local success_icon = {
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
2021-08-26 09:52:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local ms = vim.loop.hrtime() / 1000000
|
|
|
|
|
local frame = math.floor(ms / 120) % #spinners
|
2021-08-27 06:28:54 +02:00
|
|
|
|
|
|
|
|
|
if percentage >= 70 then
|
|
|
|
|
return string.format(" %%<%s %s %s (%s%%%%) ", success_icon[frame + 1], title, msg, percentage)
|
|
|
|
|
else
|
|
|
|
|
return string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage)
|
|
|
|
|
end
|
2021-08-26 09:52:48 +02:00
|
|
|
|
end
|
|
|
|
|
return ""
|
|
|
|
|
end,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 80
|
|
|
|
|
end,
|
2021-08-26 09:52:48 +02:00
|
|
|
|
hl = { fg = colors.green },
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][1] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = function()
|
2021-08-26 07:29:37 +02:00
|
|
|
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
2021-08-27 10:18:04 +02:00
|
|
|
|
return " LSP"
|
2021-08-26 07:29:37 +02:00
|
|
|
|
else
|
|
|
|
|
return ""
|
2021-08-26 07:18:13 +02:00
|
|
|
|
end
|
|
|
|
|
end,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 70
|
|
|
|
|
end,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][2] = {
|
2021-09-09 05:06:25 +02:00
|
|
|
|
provider = "git_branch",
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 70
|
|
|
|
|
end,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.grey_fg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-09-09 05:14:30 +02:00
|
|
|
|
icon = " ",
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][3] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = " " .. statusline_style.left,
|
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.one_bg2,
|
|
|
|
|
bg = colors.statusline_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-14 19:05:10 +02:00
|
|
|
|
local mode_colors = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
["n"] = { "NORMAL", colors.red },
|
|
|
|
|
["no"] = { "N-PENDING", colors.red },
|
|
|
|
|
["i"] = { "INSERT", colors.dark_purple },
|
|
|
|
|
["ic"] = { "INSERT", colors.dark_purple },
|
|
|
|
|
["t"] = { "TERMINAL", colors.green },
|
|
|
|
|
["v"] = { "VISUAL", colors.cyan },
|
|
|
|
|
["V"] = { "V-LINE", colors.cyan },
|
|
|
|
|
[""] = { "V-BLOCK", colors.cyan },
|
|
|
|
|
["R"] = { "REPLACE", colors.orange },
|
|
|
|
|
["Rv"] = { "V-REPLACE", colors.orange },
|
|
|
|
|
["s"] = { "SELECT", colors.nord_blue },
|
|
|
|
|
["S"] = { "S-LINE", colors.nord_blue },
|
|
|
|
|
[""] = { "S-BLOCK", colors.nord_blue },
|
|
|
|
|
["c"] = { "COMMAND", colors.pink },
|
|
|
|
|
["cv"] = { "COMMAND", colors.pink },
|
|
|
|
|
["ce"] = { "COMMAND", colors.pink },
|
|
|
|
|
["r"] = { "PROMPT", colors.teal },
|
|
|
|
|
["rm"] = { "MORE", colors.teal },
|
|
|
|
|
["r?"] = { "CONFIRM", colors.teal },
|
|
|
|
|
["!"] = { "SHELL", colors.green },
|
2021-08-14 19:05:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
local chad_mode_hl = function()
|
|
|
|
|
return {
|
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
bg = colors.one_bg,
|
|
|
|
|
}
|
2021-08-13 08:42:43 +02:00
|
|
|
|
end
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][4] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = statusline_style.left,
|
|
|
|
|
hl = function()
|
|
|
|
|
return {
|
|
|
|
|
fg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
bg = colors.one_bg2,
|
|
|
|
|
}
|
|
|
|
|
end,
|
2021-08-19 14:05:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][5] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = statusline_style.vi_mode_icon,
|
|
|
|
|
hl = function()
|
|
|
|
|
return {
|
|
|
|
|
fg = colors.statusline_bg,
|
|
|
|
|
bg = mode_colors[vim.fn.mode()][2],
|
|
|
|
|
}
|
|
|
|
|
end,
|
2021-08-13 08:42:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][6] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = function()
|
|
|
|
|
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
|
|
|
|
end,
|
|
|
|
|
hl = chad_mode_hl,
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][7] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = statusline_style.left,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
|
end,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.grey,
|
|
|
|
|
bg = colors.one_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][8] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = statusline_style.left,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
|
end,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.green,
|
|
|
|
|
bg = colors.grey,
|
2021-08-19 14:05:24 +02:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][9] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
provider = statusline_style.position_icon,
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
|
end,
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.black,
|
|
|
|
|
bg = colors.green,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 11:45:46 +02:00
|
|
|
|
components.active[3][10] = {
|
2021-08-26 07:18:13 +02:00
|
|
|
|
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)
|
2021-08-28 06:09:38 +02:00
|
|
|
|
return " " .. result .. "%% "
|
2021-08-26 07:18:13 +02:00
|
|
|
|
end,
|
|
|
|
|
|
2021-09-26 12:23:50 +02:00
|
|
|
|
enabled = function(winid)
|
|
|
|
|
return vim.api.nvim_win_get_width(winid) > 90
|
|
|
|
|
end,
|
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
hl = {
|
|
|
|
|
fg = colors.green,
|
|
|
|
|
bg = colors.one_bg,
|
2021-08-16 09:49:09 +02:00
|
|
|
|
},
|
2021-07-15 17:43:17 +02:00
|
|
|
|
}
|
2021-08-26 07:18:13 +02:00
|
|
|
|
|
2021-09-26 20:18:25 +02:00
|
|
|
|
local InactiveStatusHL = {
|
|
|
|
|
fg = colors.one_bg2,
|
|
|
|
|
bg = "NONE",
|
|
|
|
|
style = "underline",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
components.inactive = {
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
provider = " ",
|
|
|
|
|
hl = InactiveStatusHL,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 07:18:13 +02:00
|
|
|
|
require("feline").setup {
|
2021-09-11 07:37:04 +02:00
|
|
|
|
colors = {
|
|
|
|
|
bg = colors.statusline_bg,
|
|
|
|
|
fg = colors.fg,
|
|
|
|
|
},
|
2021-08-26 07:18:13 +02:00
|
|
|
|
components = components,
|
|
|
|
|
}
|