speedie-nvim/.config/nvim/lua/lualine_config.lua

262 lines
5.9 KiB
Lua
Raw Normal View History

2024-01-19 13:50:47 +01:00
--[[
speedie's neovim configuration
-- https://git.speedie.site/speedie/speedie-nvim --
]]--
2024-01-19 11:29:06 +01:00
local lualine = require('lualine')
-- Color table for highlights
-- stylua: ignore
local colors = {
bg = '#202328',
fg = '#bbc2cf',
2024-01-20 20:51:01 +01:00
yellow = '#ECBE7B',
2024-01-19 11:29:06 +01:00
cyan = '#008080',
2024-01-20 20:51:01 +01:00
darkblue = '#081633',
2024-01-19 11:29:06 +01:00
green = '#98be65',
2024-01-20 20:51:01 +01:00
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
2024-01-19 11:29:06 +01:00
blue = '#51afef',
red = '#ec5f67',
2024-01-20 20:51:01 +01:00
pink = '#eba8ff',
sep = '#222222',
2024-01-19 11:29:06 +01:00
}
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,
}
-- Config
local config = {
options = {
-- Disable sections and component separators
component_separators = '',
section_separators = '',
2024-01-20 15:11:21 +01:00
theme = Theme,
2024-01-19 11:29:06 +01:00
},
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_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x at right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
2024-01-20 20:51:01 +01:00
return ' '
2024-01-19 11:29:06 +01:00
end,
2024-01-20 20:51:01 +01:00
color = { fg = colors.bg }, -- Sets highlighting of component
2024-01-19 11:29:06 +01:00
padding = { left = 0, right = 1 }, -- We don't need space before this
}
ins_left {
-- mode component
function()
2024-01-19 16:02:38 +01:00
return ''
2024-01-19 11:29:06 +01:00
end,
color = function()
-- auto change color according to neovims mode
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.violet,
Rv = colors.violet,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
t = colors.red,
}
return { fg = mode_color[vim.fn.mode()] }
end,
2024-01-20 20:51:01 +01:00
padding = { right = 0 },
2024-01-19 11:29:06 +01:00
}
2024-01-20 20:51:01 +01:00
-- Some padding
2024-01-19 11:29:06 +01:00
ins_left {
2024-01-20 20:51:01 +01:00
function()
return ''
end,
color = { fg = colors.sep },
padding = { left = 3, right = 1 },
2024-01-19 11:29:06 +01:00
}
2024-01-20 20:51:01 +01:00
--[[ Looks good, but takes up quite a bit of space, so I think I'm good.
ins_left {
'datetime',
icons_enabled = true,
icon = '󰥔',
color = { fg = colors.violet, gui = 'bold' },
style = "%T",
}
--]]
ins_left {
'filetype',
fmt = string.upper,
icons_enabled = true,
icon_only = true,
color = { fg = colors.magenta, gui = 'bold' },
}
2024-01-19 11:29:06 +01:00
ins_left {
'filename',
cond = conditions.buffer_not_empty,
2024-01-20 20:51:01 +01:00
icons_enabled = false,
2024-01-19 11:29:06 +01:00
color = { fg = colors.magenta, gui = 'bold' },
}
2024-01-20 20:51:01 +01:00
ins_left {
'location',
icons_enabled = true,
icon = '';
color = { fg = colors.red, gui = 'bold' },
}
2024-01-19 11:29:06 +01:00
2024-01-20 20:51:01 +01:00
ins_left {
'progress',
icons_enabled = true,
icon = '󰹺',
color = { fg = colors.pink, gui = 'bold' },
}
2024-01-19 11:29:06 +01:00
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
},
}
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
function()
return '%='
end,
}
2024-01-20 20:51:01 +01:00
ins_right {
-- search component
'searchcount',
icons_enabled = true,
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
-- filesize component
'filesize',
icons_enabled = true,
icon = '󰉉',
color = { fg = colors.orange, gui = 'bold' },
cond = conditions.buffer_not_empty,
}
2024-01-19 11:29:06 +01:00
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- I'm not sure why it's upper case either ;)
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
2024-01-20 20:51:01 +01:00
icons_enabled = true,
icon = '󰉢';
2024-01-19 11:29:06 +01:00
}
2024-01-21 22:41:37 +01:00
ins_right {
'aerial',
sep = " ) ",
depth = nil,
colored = false,
color = { fg = colors.pink, gui = 'bold' },
}
2024-01-19 11:29:06 +01:00
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
symbols = { added = '', modified = '󰝤 ', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
2024-01-20 20:51:01 +01:00
ins_right {
'fileformat',
fmt = string.upper,
symbols = {
unix = '',
dos = '',
mac = '',
},
icons_enabled = true,
color = { fg = colors.blue, gui = 'bold' },
}
-- Some padding
2024-01-19 11:29:06 +01:00
ins_right {
function()
2024-01-20 20:51:01 +01:00
return ' '
2024-01-19 11:29:06 +01:00
end,
2024-01-20 20:51:01 +01:00
color = { fg = colors.bg },
2024-01-19 11:29:06 +01:00
padding = { left = 1 },
}
-- Now don't forget to initialize lualine
lualine.setup(config)