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, {})
|
||||
|
||||
components.active[1][1] = {
|
||||
local get_components = function()
|
||||
local M = {}
|
||||
|
||||
M.main_icon = {
|
||||
provider = statusline_style.main_icon,
|
||||
|
||||
hl = {
|
||||
@ -76,7 +79,7 @@ components.active[1][1] = {
|
||||
} },
|
||||
}
|
||||
|
||||
components.active[1][2] = {
|
||||
M.file = {
|
||||
provider = function()
|
||||
local filename = vim.fn.expand "%:t"
|
||||
local extension = vim.fn.expand "%:e"
|
||||
@ -98,7 +101,7 @@ components.active[1][2] = {
|
||||
right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } },
|
||||
}
|
||||
|
||||
components.active[1][3] = {
|
||||
M.dir = {
|
||||
provider = function()
|
||||
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
|
||||
return " " .. dir_name .. " "
|
||||
@ -121,7 +124,7 @@ components.active[1][3] = {
|
||||
},
|
||||
}
|
||||
|
||||
components.active[1][4] = {
|
||||
M.git_added = {
|
||||
provider = "git_diff_added",
|
||||
hl = {
|
||||
fg = colors.grey_fg2,
|
||||
@ -129,8 +132,8 @@ components.active[1][4] = {
|
||||
},
|
||||
icon = " ",
|
||||
}
|
||||
-- diffModfified
|
||||
components.active[1][5] = {
|
||||
|
||||
M.git_modified = {
|
||||
provider = "git_diff_changed",
|
||||
hl = {
|
||||
fg = colors.grey_fg2,
|
||||
@ -138,8 +141,8 @@ components.active[1][5] = {
|
||||
},
|
||||
icon = " ",
|
||||
}
|
||||
-- diffRemove
|
||||
components.active[1][6] = {
|
||||
|
||||
M.git_removed = {
|
||||
provider = "git_diff_removed",
|
||||
hl = {
|
||||
fg = colors.grey_fg2,
|
||||
@ -148,7 +151,7 @@ components.active[1][6] = {
|
||||
icon = " ",
|
||||
}
|
||||
|
||||
components.active[1][7] = {
|
||||
M.diagnostic_errors = {
|
||||
provider = "diagnostic_errors",
|
||||
enabled = function()
|
||||
return lsp.diagnostics_exist(lsp_severity.ERROR)
|
||||
@ -158,7 +161,7 @@ components.active[1][7] = {
|
||||
icon = " ",
|
||||
}
|
||||
|
||||
components.active[1][8] = {
|
||||
M.diagnostic_warnings= {
|
||||
provider = "diagnostic_warnings",
|
||||
enabled = function()
|
||||
return lsp.diagnostics_exist(lsp_severity.WARN)
|
||||
@ -167,7 +170,7 @@ components.active[1][8] = {
|
||||
icon = " ",
|
||||
}
|
||||
|
||||
components.active[1][9] = {
|
||||
M.diagnostic_hints = {
|
||||
provider = "diagnostic_hints",
|
||||
enabled = function()
|
||||
return lsp.diagnostics_exist(lsp_severity.HINT)
|
||||
@ -176,7 +179,7 @@ components.active[1][9] = {
|
||||
icon = " ",
|
||||
}
|
||||
|
||||
components.active[1][10] = {
|
||||
M.dianostic_info ={
|
||||
provider = "diagnostic_info",
|
||||
enabled = function()
|
||||
return lsp.diagnostics_exist(lsp_severity.INFO)
|
||||
@ -185,7 +188,7 @@ components.active[1][10] = {
|
||||
icon = " ",
|
||||
}
|
||||
|
||||
components.active[2][1] = {
|
||||
M.lsp_progress = {
|
||||
provider = function()
|
||||
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
||||
|
||||
@ -223,7 +226,7 @@ components.active[2][1] = {
|
||||
hl = { fg = colors.green },
|
||||
}
|
||||
|
||||
components.active[3][1] = {
|
||||
M.lsp = {
|
||||
provider = function()
|
||||
if next(vim.lsp.buf_get_clients()) ~= nil then
|
||||
return " LSP"
|
||||
@ -237,7 +240,7 @@ components.active[3][1] = {
|
||||
hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
|
||||
}
|
||||
|
||||
components.active[3][2] = {
|
||||
M.git_branch = {
|
||||
provider = "git_branch",
|
||||
enabled = shortline or function(winid)
|
||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70
|
||||
@ -249,7 +252,7 @@ components.active[3][2] = {
|
||||
icon = " ",
|
||||
}
|
||||
|
||||
components.active[3][3] = {
|
||||
M.git_right_separator = {
|
||||
provider = " " .. statusline_style.left,
|
||||
hl = {
|
||||
fg = colors.one_bg2,
|
||||
@ -287,7 +290,7 @@ local chad_mode_hl = function()
|
||||
}
|
||||
end
|
||||
|
||||
components.active[3][4] = {
|
||||
M.mode_left_separator = {
|
||||
provider = statusline_style.left,
|
||||
hl = function()
|
||||
return {
|
||||
@ -297,7 +300,7 @@ components.active[3][4] = {
|
||||
end,
|
||||
}
|
||||
|
||||
components.active[3][5] = {
|
||||
M.mode_icon = {
|
||||
provider = statusline_style.vi_mode_icon,
|
||||
hl = function()
|
||||
return {
|
||||
@ -307,14 +310,14 @@ components.active[3][5] = {
|
||||
end,
|
||||
}
|
||||
|
||||
components.active[3][6] = {
|
||||
M.mode_string = {
|
||||
provider = function()
|
||||
return " " .. mode_colors[vim.fn.mode()][1] .. " "
|
||||
end,
|
||||
hl = chad_mode_hl,
|
||||
}
|
||||
|
||||
components.active[3][7] = {
|
||||
M.loc_spacer_left = {
|
||||
provider = statusline_style.left,
|
||||
enabled = shortline or function(winid)
|
||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
||||
@ -322,10 +325,10 @@ components.active[3][7] = {
|
||||
hl = {
|
||||
fg = colors.grey,
|
||||
bg = colors.one_bg,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
components.active[3][8] = {
|
||||
M.loc_separator_left = {
|
||||
provider = statusline_style.left,
|
||||
enabled = shortline or function(winid)
|
||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
||||
@ -336,7 +339,7 @@ components.active[3][8] = {
|
||||
},
|
||||
}
|
||||
|
||||
components.active[3][9] = {
|
||||
M.loc_position_icon = {
|
||||
provider = statusline_style.position_icon,
|
||||
enabled = shortline or function(winid)
|
||||
return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90
|
||||
@ -344,10 +347,10 @@ components.active[3][9] = {
|
||||
hl = {
|
||||
fg = colors.black,
|
||||
bg = colors.green,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
components.active[3][10] = {
|
||||
M.loc_position_text = {
|
||||
provider = function()
|
||||
local current_line = vim.fn.line "."
|
||||
local total_line = vim.fn.line "$"
|
||||
@ -370,6 +373,46 @@ components.active[3][10] = {
|
||||
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 {
|
||||
theme = {
|
||||
|
Loading…
Reference in New Issue
Block a user