refactor custom components
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"rmehri01/onenord.nvim",
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
'rmehri01/onenord.nvim',
|
||||
},
|
||||
event = "VeryLazy",
|
||||
event = 'VeryLazy',
|
||||
config = function()
|
||||
local lualine = require("lualine")
|
||||
local lazy_status = require("lazy.status")
|
||||
local lualine = require('lualine')
|
||||
local lazy_status = require('lazy.status')
|
||||
|
||||
local custom_components = {
|
||||
-- ┌
|
||||
@@ -15,7 +15,7 @@ return {
|
||||
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
||||
-- └
|
||||
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
|
||||
end,
|
||||
|
||||
@@ -24,12 +24,25 @@ return {
|
||||
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
||||
-- └
|
||||
fileformat = function()
|
||||
local ret, _ = vim.bo.fileformat:gsub("^unix$", "")
|
||||
local ret, _ = vim.bo.fileformat:gsub('^unix$', '')
|
||||
return ret
|
||||
end,
|
||||
}
|
||||
|
||||
local function gitsigns_diff()
|
||||
-- ┌
|
||||
-- │ get width of current window
|
||||
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
||||
-- └
|
||||
min_window_width = function(width)
|
||||
return function()
|
||||
return vim.fn.winwidth(0) > width
|
||||
end
|
||||
end,
|
||||
|
||||
-- ┌
|
||||
-- │ get diff for current buffer from gitsigns
|
||||
-- │ doing this for yadm integration from gitsigns
|
||||
-- └
|
||||
gitsigns_diff = function()
|
||||
local gitsigns = vim.b.gitsigns_status_dict
|
||||
if gitsigns then
|
||||
return {
|
||||
@@ -38,19 +51,20 @@ return {
|
||||
removed = gitsigns.removed,
|
||||
}
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "onenord",
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
theme = 'onenord',
|
||||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = '' },
|
||||
disabled_filetypes = {
|
||||
statusline = { "alpha", "dashboard", "Outline" },
|
||||
statusline = { 'alpha', 'dashboard', 'Outline' },
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = { "NvimTree" },
|
||||
ignore_focus = { 'NvimTree' },
|
||||
always_divide_middle = true,
|
||||
always_show_tabline = true,
|
||||
globalstatus = false,
|
||||
@@ -61,74 +75,79 @@ return {
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_a = { 'mode', { cond = custom_components.min_window_width(40) } },
|
||||
lualine_b = {
|
||||
{
|
||||
"filename",
|
||||
'filename',
|
||||
file_status = true,
|
||||
newfile_status = true,
|
||||
path = 4,
|
||||
symbols = {
|
||||
modified = "[+]",
|
||||
readonly = "[-]",
|
||||
modified = '[+]',
|
||||
readonly = '[-]',
|
||||
},
|
||||
},
|
||||
},
|
||||
lualine_c = {
|
||||
"branch",
|
||||
-- TODO: make it prettier...
|
||||
{ "b:gitsigns_head", icon = "" },
|
||||
{ "diff", source = gitsigns_diff },
|
||||
'branch',
|
||||
{
|
||||
'b:gitsigns_head',
|
||||
icon = '',
|
||||
color = { fg = '#9bcb8b' },
|
||||
{ cond = custom_components.min_window_width(120) },
|
||||
},
|
||||
{ 'diff', source = custom_components.gitsigns_diff },
|
||||
},
|
||||
lualine_x = {
|
||||
-- TODO: spell indicator (when on)
|
||||
-- TODO: LSP
|
||||
-- TODO: macro indicator
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_workspace_diagnostic" },
|
||||
sections = { "error", "warn", "info", "hint" },
|
||||
'diagnostics',
|
||||
sources = { 'nvim_workspace_diagnostic' },
|
||||
sections = { 'error', 'warn', 'info', 'hint' },
|
||||
--symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
||||
colored = true,
|
||||
always_visible = false,
|
||||
},
|
||||
{
|
||||
lazy_status.updates,
|
||||
cond = lazy_status.has_updates,
|
||||
color = { fg = "#ebcb8b" },
|
||||
{ { cond = lazy_status.has_updates and custom_components.min_window_width(120) } },
|
||||
color = { fg = '#ebcb8b' },
|
||||
},
|
||||
-- {
|
||||
-- function()
|
||||
-- return require("auto-session.lib").current_session_name(true)
|
||||
-- end,
|
||||
-- },
|
||||
{ custom_components.encoding },
|
||||
{ custom_components.fileformat },
|
||||
"filetype",
|
||||
{ custom_components.encoding, { cond = custom_components.min_window_width(120) } },
|
||||
{ custom_components.fileformat, { cond = custom_components.min_window_width(120) } },
|
||||
'filetype',
|
||||
},
|
||||
lualine_y = { "searchcount", "progress" },
|
||||
lualine_z = { "selectioncount", "location" },
|
||||
lualine_y = { 'searchcount', 'progress' },
|
||||
lualine_z = { 'selectioncount', 'location' },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = {
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_lsp", "nvim_workspace_diagnostic", "nvim_diagnostic" },
|
||||
sections = { "error", "warn", "info", "hint" },
|
||||
'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" },
|
||||
lualine_z = { 'location' },
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = { "nvim-tree", "lazy", "trouble", "quickfix", "fzf", "mason" },
|
||||
extensions = { 'nvim-tree', 'lazy', 'trouble', 'quickfix', 'fzf', 'mason' },
|
||||
})
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user