dotfiles/nvim/.config/nvim/after/plugin/lualine.lua

151 lines
3.3 KiB
Lua

local colors = {
line_bg = '#21242b',
bg = '#000000',
fg = '#dobfa1',
yellow = '#fabd2f',
cyan = '#008080',
darkblue = '#081633',
green = '#afd700',
orange = '#FF8800',
purple = '#5d4d7a',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67'
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand '%:t') ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand '%:p:h'
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
check_active_lsp = function()
local clients = vim.lsp.get_active_clients()
return next(clients) ~= nil
end
}
local window = {
function()
return vim.api.nvim_win_get_number(0)
end,
color = { fg = colors.red },
}
local function diffsigns_source()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed
}
end
end
local config = {
options = {
component_separators = '',
section_separators = '',
theme = {
normal = { c = { fg = colors.fg , bg = colors.bg } },
inactive = { c = { fg = colors.yellow, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = { window },
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_v = {},
lualine_y = {},
lualine_z = {},
lualine_c = { window, 'filename' },
lualine_x = { 'location', 'progress' },
},
extensions = { 'fugitive', 'fzf', 'quickfix', 'toggleterm' },
}
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.blue, gui = 'bold' },
}
ins_left {
'FugitiveHead',
cond = conditions.check_git_workspace,
color = { fg = colors.orange, gui = 'bold' },
}
ins_left {
'diff',
source = diffsigns_source,
cond = conditions.check_git_workspace,
symbols = { added = '+', modified = '~', removed = '-' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
}
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = 'E:', warn = 'W:', info = 'I:', hint = 'H:' },
diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
color_hint = { fg = colors.orange },
},
}
ins_left {
function()
return '%='
end,
}
ins_right {
'lsp_progress',
cond = conditions.check_active_lsp and conditions.hide_in_width,
color = { fg = colors.cyan, gui = 'bold' }
}
ins_right {
'location',
color = { fg = colors.green, gui = 'bold' }
}
ins_right {
'progress',
color = { fg = colors.magenta, gui = 'bold' }
}
require'lualine'.setup(config)