refactor custom components

This commit is contained in:
2024-11-25 08:51:09 -05:00
parent 96bcf5d850
commit 901c484ebb
+147 -128
View File
@@ -1,134 +1,153 @@
return { return {
"nvim-lualine/lualine.nvim", 'nvim-lualine/lualine.nvim',
dependencies = { dependencies = {
"nvim-tree/nvim-web-devicons", 'nvim-tree/nvim-web-devicons',
"rmehri01/onenord.nvim", 'rmehri01/onenord.nvim',
}, },
event = "VeryLazy", event = 'VeryLazy',
config = function() config = function()
local lualine = require("lualine") local lualine = require('lualine')
local lazy_status = require("lazy.status") local lazy_status = require('lazy.status')
local custom_components = { local custom_components = {
-- ┌ -- ┌
-- │ do not show encoding if UTF-8 -- │ do not show encoding if UTF-8
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua -- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
-- └ -- └
encoding = function() encoding = function()
local ret, _ = (vim.bo.fenc or vim.go.enc):gsub("^utf%-8$", "") local ret, _ = (vim.bo.fenc or vim.go.enc):gsub('^utf%-8$', '')
return ret return ret
end, end,
-- ┌ -- ┌
-- │ only show non-unix file format -- │ only show non-unix file format
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua -- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
-- └ -- └
fileformat = function() fileformat = function()
local ret, _ = vim.bo.fileformat:gsub("^unix$", "") local ret, _ = vim.bo.fileformat:gsub('^unix$', '')
return ret return ret
end, end,
}
local function gitsigns_diff() -- ┌
local gitsigns = vim.b.gitsigns_status_dict -- │ get width of current window
if gitsigns then -- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
return { -- └
added = gitsigns.added, min_window_width = function(width)
modified = gitsigns.changed, return function()
removed = gitsigns.removed, return vim.fn.winwidth(0) > width
} end
end end,
end
lualine.setup({ -- ┌
options = { -- │ get diff for current buffer from gitsigns
icons_enabled = true, -- │ doing this for yadm integration from gitsigns
theme = "onenord", -- └
component_separators = { left = "", right = "" }, gitsigns_diff = function()
section_separators = { left = "", right = "" }, local gitsigns = vim.b.gitsigns_status_dict
disabled_filetypes = { if gitsigns then
statusline = { "alpha", "dashboard", "Outline" }, return {
winbar = {}, added = gitsigns.added,
}, modified = gitsigns.changed,
ignore_focus = { "NvimTree" }, removed = gitsigns.removed,
always_divide_middle = true, }
always_show_tabline = true, end
globalstatus = false, end,
refresh = { }
statusline = 1000,
tabline = 1000, lualine.setup({
winbar = 1000, options = {
}, icons_enabled = true,
}, theme = 'onenord',
sections = { component_separators = { left = '', right = '' },
lualine_a = { "mode" }, section_separators = { left = '', right = '' },
lualine_b = { disabled_filetypes = {
{ statusline = { 'alpha', 'dashboard', 'Outline' },
"filename", winbar = {},
file_status = true,
newfile_status = true,
path = 4,
symbols = {
modified = "[+]",
readonly = "[-]",
}, },
}, ignore_focus = { 'NvimTree' },
}, always_divide_middle = true,
lualine_c = { always_show_tabline = true,
"branch", globalstatus = false,
-- TODO: make it prettier... refresh = {
{ "b:gitsigns_head", icon = "" }, statusline = 1000,
{ "diff", source = gitsigns_diff }, tabline = 1000,
}, winbar = 1000,
lualine_x = { },
-- TODO: spell indicator (when on) },
-- TODO: LSP sections = {
{ lualine_a = { 'mode', { cond = custom_components.min_window_width(40) } },
"diagnostics", lualine_b = {
sources = { "nvim_workspace_diagnostic" }, {
sections = { "error", "warn", "info", "hint" }, 'filename',
--symbols = { error = " ", warn = " ", info = " ", hint = "󰠠 " }, file_status = true,
colored = true, newfile_status = true,
always_visible = false, path = 4,
}, symbols = {
{ modified = '[+]',
lazy_status.updates, readonly = '[-]',
cond = lazy_status.has_updates, },
color = { fg = "#ebcb8b" }, },
}, },
-- { lualine_c = {
-- function() 'branch',
-- return require("auto-session.lib").current_session_name(true) {
-- end, 'b:gitsigns_head',
-- }, icon = '',
{ custom_components.encoding }, color = { fg = '#9bcb8b' },
{ custom_components.fileformat }, { cond = custom_components.min_window_width(120) },
"filetype", },
}, { 'diff', source = custom_components.gitsigns_diff },
lualine_y = { "searchcount", "progress" }, },
lualine_z = { "selectioncount", "location" }, lualine_x = {
}, -- TODO: spell indicator (when on)
inactive_sections = { -- TODO: LSP
lualine_a = {}, -- TODO: macro indicator
lualine_b = {}, {
lualine_c = { "filename" }, 'diagnostics',
lualine_x = { sources = { 'nvim_workspace_diagnostic' },
{ sections = { 'error', 'warn', 'info', 'hint' },
"diagnostics", --symbols = { error = " ", warn = " ", info = " ", hint = "󰠠 " },
sources = { "nvim_lsp", "nvim_workspace_diagnostic", "nvim_diagnostic" }, colored = true,
sections = { "error", "warn", "info", "hint" }, always_visible = false,
--symbols = { error = " ", warn = " ", info = " ", hint = "󰠠 " }, },
colored = false, {
always_visible = false, lazy_status.updates,
}, { { cond = lazy_status.has_updates and custom_components.min_window_width(120) } },
}, color = { fg = '#ebcb8b' },
lualine_y = {}, },
lualine_z = { "location" }, -- {
}, -- function()
tabline = {}, -- return require("auto-session.lib").current_session_name(true)
winbar = {}, -- end,
inactive_winbar = {}, -- },
extensions = { "nvim-tree", "lazy", "trouble", "quickfix", "fzf", "mason" }, { custom_components.encoding, { cond = custom_components.min_window_width(120) } },
}) { custom_components.fileformat, { cond = custom_components.min_window_width(120) } },
end, 'filetype',
} },
lualine_y = { 'searchcount', 'progress' },
lualine_z = { 'selectioncount', 'location' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = {
{
'diagnostics',
sources = { 'nvim_lsp', 'nvim_workspace_diagnostic', 'nvim_diagnostic' },
sections = { 'error', 'warn', 'info', 'hint' },
--symbols = { error = " ", warn = " ", info = " ", hint = "󰠠 " },
colored = false,
always_visible = false,
},
},
lualine_y = {},
lualine_z = { 'location' },
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = { 'nvim-tree', 'lazy', 'trouble', 'quickfix', 'fzf', 'mason' },
})
end,
}