rewrote statusline to be compartmentalized into named components and easier to understand/customize as a basis
This commit is contained in:
parent
8c2bbd2143
commit
fa9f9aad0b
@ -62,7 +62,10 @@ table.insert(components.active, {})
|
|||||||
table.insert(components.active, {})
|
table.insert(components.active, {})
|
||||||
table.insert(components.active, {})
|
table.insert(components.active, {})
|
||||||
|
|
||||||
components.active[1][1] = {
|
local get_components = function()
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.main_icon = {
|
||||||
provider = statusline_style.main_icon,
|
provider = statusline_style.main_icon,
|
||||||
|
|
||||||
hl = {
|
hl = {
|
||||||
@ -74,9 +77,9 @@ components.active[1][1] = {
|
|||||||
fg = colors.nord_blue,
|
fg = colors.nord_blue,
|
||||||
bg = colors.lightbg,
|
bg = colors.lightbg,
|
||||||
} },
|
} },
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][2] = {
|
M.file = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local filename = vim.fn.expand "%:t"
|
local filename = vim.fn.expand "%:t"
|
||||||
local extension = vim.fn.expand "%:e"
|
local extension = vim.fn.expand "%:e"
|
||||||
@ -96,9 +99,9 @@ components.active[1][2] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } },
|
right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } },
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][3] = {
|
M.dir = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
||||||
return " " .. dir_name .. " "
|
return " " .. dir_name .. " "
|
||||||
@ -119,36 +122,36 @@ components.active[1][3] = {
|
|||||||
bg = colors.statusline_bg,
|
bg = colors.statusline_bg,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][4] = {
|
M.git_added = {
|
||||||
provider = "git_diff_added",
|
provider = "git_diff_added",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
-- diffModfified
|
|
||||||
components.active[1][5] = {
|
M.git_modified = {
|
||||||
provider = "git_diff_changed",
|
provider = "git_diff_changed",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
-- diffRemove
|
|
||||||
components.active[1][6] = {
|
M.git_removed = {
|
||||||
provider = "git_diff_removed",
|
provider = "git_diff_removed",
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey_fg2,
|
fg = colors.grey_fg2,
|
||||||
bg = colors.statusline_bg,
|
bg = colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][7] = {
|
M.diagnostic_errors = {
|
||||||
provider = "diagnostic_errors",
|
provider = "diagnostic_errors",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
||||||
@ -156,36 +159,36 @@ components.active[1][7] = {
|
|||||||
|
|
||||||
hl = { fg = colors.red },
|
hl = { fg = colors.red },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][8] = {
|
M.diagnostic_warnings= {
|
||||||
provider = "diagnostic_warnings",
|
provider = "diagnostic_warnings",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.WARN)
|
return lsp.diagnostics_exist(lsp_severity.WARN)
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.yellow },
|
hl = { fg = colors.yellow },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][9] = {
|
M.diagnostic_hints = {
|
||||||
provider = "diagnostic_hints",
|
provider = "diagnostic_hints",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.HINT)
|
return lsp.diagnostics_exist(lsp_severity.HINT)
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.grey_fg2 },
|
hl = { fg = colors.grey_fg2 },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[1][10] = {
|
M.dianostic_info ={
|
||||||
provider = "diagnostic_info",
|
provider = "diagnostic_info",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return lsp.diagnostics_exist(lsp_severity.INFO)
|
return lsp.diagnostics_exist(lsp_severity.INFO)
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.green },
|
hl = { fg = colors.green },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[2][1] = {
|
M.lsp_progress = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
||||||
|
|
||||||
@ -221,9 +224,9 @@ components.active[2][1] = {
|
|||||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 80
|
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 80
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.green },
|
hl = { fg = colors.green },
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][1] = {
|
M.lsp = {
|
||||||
provider = function()
|
provider = function()
|
||||||
if next(vim.lsp.buf_get_clients()) ~= nil then
|
if next(vim.lsp.buf_get_clients()) ~= nil then
|
||||||
return " LSP"
|
return " LSP"
|
||||||
@ -235,9 +238,9 @@ components.active[3][1] = {
|
|||||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
|
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
|
||||||
end,
|
end,
|
||||||
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
|
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][2] = {
|
M.git_branch = {
|
||||||
provider = "git_branch",
|
provider = "git_branch",
|
||||||
enabled = shortline or function(winid)
|
enabled = shortline or function(winid)
|
||||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
|
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
|
||||||
@ -247,17 +250,17 @@ components.active[3][2] = {
|
|||||||
bg = colors.statusline_bg,
|
bg = colors.statusline_bg,
|
||||||
},
|
},
|
||||||
icon = " ",
|
icon = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][3] = {
|
M.git_right_separator = {
|
||||||
provider = " " .. statusline_style.left,
|
provider = " " .. statusline_style.left,
|
||||||
hl = {
|
hl = {
|
||||||
fg = colors.one_bg2,
|
fg = colors.one_bg2,
|
||||||
bg = colors.statusline_bg,
|
bg = colors.statusline_bg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local mode_colors = {
|
local mode_colors = {
|
||||||
["n"] = { "NORMAL", colors.red },
|
["n"] = { "NORMAL", colors.red },
|
||||||
["no"] = { "N-PENDING", colors.red },
|
["no"] = { "N-PENDING", colors.red },
|
||||||
["i"] = { "INSERT", colors.dark_purple },
|
["i"] = { "INSERT", colors.dark_purple },
|
||||||
@ -278,16 +281,16 @@ local mode_colors = {
|
|||||||
["rm"] = { "MORE", colors.teal },
|
["rm"] = { "MORE", colors.teal },
|
||||||
["r?"] = { "CONFIRM", colors.teal },
|
["r?"] = { "CONFIRM", colors.teal },
|
||||||
["!"] = { "SHELL", colors.green },
|
["!"] = { "SHELL", colors.green },
|
||||||
}
|
}
|
||||||
|
|
||||||
local chad_mode_hl = function()
|
local chad_mode_hl = function()
|
||||||
return {
|
return {
|
||||||
fg = mode_colors[vim.fn.mode()][2],
|
fg = mode_colors[vim.fn.mode()][2],
|
||||||
bg = colors.one_bg,
|
bg = colors.one_bg,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
components.active[3][4] = {
|
M.mode_left_separator = {
|
||||||
provider = statusline_style.left,
|
provider = statusline_style.left,
|
||||||
hl = function()
|
hl = function()
|
||||||
return {
|
return {
|
||||||
@ -295,9 +298,9 @@ components.active[3][4] = {
|
|||||||
bg = colors.one_bg2,
|
bg = colors.one_bg2,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][5] = {
|
M.mode_icon = {
|
||||||
provider = statusline_style.vi_mode_icon,
|
provider = statusline_style.vi_mode_icon,
|
||||||
hl = function()
|
hl = function()
|
||||||
return {
|
return {
|
||||||
@ -305,16 +308,16 @@ components.active[3][5] = {
|
|||||||
bg = mode_colors[vim.fn.mode()][2],
|
bg = mode_colors[vim.fn.mode()][2],
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][6] = {
|
M.mode_string = {
|
||||||
provider = function()
|
provider = function()
|
||||||
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
||||||
end,
|
end,
|
||||||
hl = chad_mode_hl,
|
hl = chad_mode_hl,
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][7] = {
|
M.loc_spacer_left = {
|
||||||
provider = statusline_style.left,
|
provider = statusline_style.left,
|
||||||
enabled = shortline or function(winid)
|
enabled = shortline or function(winid)
|
||||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
||||||
@ -322,10 +325,10 @@ components.active[3][7] = {
|
|||||||
hl = {
|
hl = {
|
||||||
fg = colors.grey,
|
fg = colors.grey,
|
||||||
bg = colors.one_bg,
|
bg = colors.one_bg,
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][8] = {
|
M.loc_separator_left = {
|
||||||
provider = statusline_style.left,
|
provider = statusline_style.left,
|
||||||
enabled = shortline or function(winid)
|
enabled = shortline or function(winid)
|
||||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
||||||
@ -334,9 +337,9 @@ components.active[3][8] = {
|
|||||||
fg = colors.green,
|
fg = colors.green,
|
||||||
bg = colors.grey,
|
bg = colors.grey,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][9] = {
|
M.loc_position_icon = {
|
||||||
provider = statusline_style.position_icon,
|
provider = statusline_style.position_icon,
|
||||||
enabled = shortline or function(winid)
|
enabled = shortline or function(winid)
|
||||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
||||||
@ -344,10 +347,10 @@ components.active[3][9] = {
|
|||||||
hl = {
|
hl = {
|
||||||
fg = colors.black,
|
fg = colors.black,
|
||||||
bg = colors.green,
|
bg = colors.green,
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
components.active[3][10] = {
|
M.loc_position_text = {
|
||||||
provider = function()
|
provider = function()
|
||||||
local current_line = vim.fn.line "."
|
local current_line = vim.fn.line "."
|
||||||
local total_line = vim.fn.line "$"
|
local total_line = vim.fn.line "$"
|
||||||
@ -369,7 +372,47 @@ components.active[3][10] = {
|
|||||||
fg = colors.green,
|
fg = colors.green,
|
||||||
bg = colors.one_bg,
|
bg = colors.one_bg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
return M
|
||||||
|
end
|
||||||
|
|
||||||
|
local components_list = get_components()
|
||||||
|
|
||||||
|
local left = {}
|
||||||
|
local right = {}
|
||||||
|
local middle = {}
|
||||||
|
|
||||||
|
table.insert(left, components_list.main_icon)
|
||||||
|
table.insert(left, components_list.file)
|
||||||
|
table.insert(left, components_list.dir)
|
||||||
|
|
||||||
|
table.insert(left, components_list.git_added)
|
||||||
|
table.insert(left, components_list.git_modified)
|
||||||
|
table.insert(left, components_list.git_removed)
|
||||||
|
|
||||||
|
table.insert(left, components_list.diagnostic_errors)
|
||||||
|
table.insert(left, components_list.diagnostic_warnings)
|
||||||
|
table.insert(left, components_list.diagnostic_hints)
|
||||||
|
table.insert(left, components_list.diagnostic_info)
|
||||||
|
|
||||||
|
table.insert(middle, components_list.lsp_progress)
|
||||||
|
|
||||||
|
table.insert(right, components_list.lsp)
|
||||||
|
table.insert(right, components_list.git_branch)
|
||||||
|
table.insert(right, components_list.git_right_separator)
|
||||||
|
|
||||||
|
table.insert(right, components_list.mode_left_separator)
|
||||||
|
table.insert(right, components_list.mode_mode_icon)
|
||||||
|
table.insert(right, components_list.mode_mode_string)
|
||||||
|
|
||||||
|
table.insert(right, components_list.loc_spacer_left)
|
||||||
|
table.insert(right, components_list.loc_separator_left)
|
||||||
|
table.insert(right, components_list.loc_position_icon)
|
||||||
|
table.insert(right, components_list.loc_position_text)
|
||||||
|
|
||||||
|
components.active[1] = left
|
||||||
|
components.active[2] = middle
|
||||||
|
components.active[3] = right
|
||||||
|
|
||||||
require("feline").setup {
|
require("feline").setup {
|
||||||
theme = {
|
theme = {
|
||||||
|
Loading…
Reference in New Issue
Block a user