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

192 lines
4.2 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 = {
icons_enabled = true,
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 = {},
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 {
function()
return ' '
end,
color = { fg = colors.blue },
padding = { left = 0, right = 1 },
}
ins_left {
function()
local mode_color = {
n = colors.red,
i = colors.green,
v = colors.blue,
[''] = colors.blue,
V = colors.blue,
c = colors.magenta,
no = colors.red,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.purple,
Rv = colors.purple,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
t = colors.red,
}
vim.api.nvim_command('hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. ' guibg=' .. colors.bg)
return ''
end,
color = 'LualineMode',
padding = { right = 1 },
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.blue, gui = 'bold' },
}
ins_left {
'FugitiveHead',
cond = conditions.check_git_workspace,
icon = '',
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 = '', warn = '', info = '', hint = '' },
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)