Feat: buffer title on the middle

This commit is contained in:
Bertrand Benjamin 2021-11-01 14:52:47 +01:00
parent f133c72653
commit 829bf55d82

View File

@ -34,9 +34,10 @@ local config = {
-- Disable sections and component separators -- Disable sections and component separators
component_separators = "", component_separators = "",
section_separators = "", section_separators = "",
-- theme = 'gruvbox',
theme = { theme = {
-- We are going to use lualine_c an lualine_x as left and -- We are going to use lualine_c an lualine_x as left and
-- right section. Both are highlighted by c theme . So we -- right section. both are highlighted by c theme . so we
-- are just setting default looks o statusline -- are just setting default looks o statusline
normal = {c = {fg = colors.fg, bg = colors.bg}}, normal = {c = {fg = colors.fg, bg = colors.bg}},
inactive = {c = {fg = colors.fg, bg = colors.bg}} inactive = {c = {fg = colors.fg, bg = colors.bg}}
@ -48,7 +49,7 @@ local config = {
lualine_b = {}, lualine_b = {},
lualine_y = {}, lualine_y = {},
lualine_z = {}, lualine_z = {},
-- These will be filled later -- these will be filled later
lualine_c = {}, lualine_c = {},
lualine_x = {} lualine_x = {}
}, },
@ -63,40 +64,30 @@ local config = {
} }
} }
-- Inserts a component in lualine_c at left section -- inserts a component in lualine_c at left section
local function ins_left(component) local function ins_left(component)
table.insert(config.sections.lualine_c, component) table.insert(config.sections.lualine_c, component)
end end
-- Inserts a component in lualine_x ot right section -- inserts a component in lualine_x ot right section
local function ins_right(component) local function ins_right(component)
table.insert(config.sections.lualine_x, component) table.insert(config.sections.lualine_x, component)
end end
ins_left {
function() return '' end,
color = {fg = colors.blue}, -- Sets highlighting of component
left_padding = 0 -- We don't need space before this
}
ins_left {
-- mode component
function()
-- auto change color according to neovims mode
local mode_color = { local mode_color = {
n = colors.red, n = colors.red,
i = colors.green, i = colors.green,
v = colors.blue, v = colors.blue,
[''] = colors.blue, [''] = colors.blue,
V = colors.blue, v = colors.blue,
c = colors.magenta, c = colors.magenta,
no = colors.red, no = colors.red,
s = colors.orange, s = colors.orange,
S = colors.orange, s = colors.orange,
[''] = colors.orange, [''] = colors.orange,
ic = colors.yellow, ic = colors.yellow,
R = colors.violet, r = colors.violet,
Rv = colors.violet, rv = colors.violet,
cv = colors.red, cv = colors.red,
ce = colors.red, ce = colors.red,
r = colors.cyan, r = colors.cyan,
@ -105,15 +96,24 @@ ins_left {
['!'] = colors.red, ['!'] = colors.red,
t = colors.red t = colors.red
} }
ins_left {
-- mode component
function()
-- auto change color according to neovims mode
vim.api.nvim_command( vim.api.nvim_command(
'hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. " guibg=" .. 'hi! lualinemode guifg=' .. mode_color[vim.fn.mode()] .. " guibg=" .. colors.bg)
colors.bg)
return '' return ''
end, end,
color = "LualineMode", color = "lualinemode",
left_padding = 0 left_padding = 0
} }
ins_left {
"mode",
color = {fg = colors.green, gui = 'bold'}
}
ins_left { ins_left {
-- filesize component -- filesize component
function() function()
@ -134,30 +134,6 @@ ins_left {
end, end,
condition = conditions.buffer_not_empty condition = conditions.buffer_not_empty
} }
ins_left {
'filename',
condition = conditions.buffer_not_empty,
color = {fg = colors.magenta, gui = 'bold'}
}
ins_left {'location'}
ins_left {'progress', color = {fg = colors.fg, gui = 'bold'}}
ins_left {
'diagnostics',
sources = {'nvim_lsp'},
symbols = {error = '', warn = '', info = ''},
color_error = colors.red,
color_warn = colors.yellow,
color_info = 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}
ins_left { ins_left {
-- Lsp server name . -- Lsp server name .
function() function()
@ -177,6 +153,25 @@ ins_left {
color = {fg = '#ffffff', gui = 'bold'} color = {fg = '#ffffff', gui = 'bold'}
} }
ins_left {
'diagnostics',
sources = {'nvim_lsp'},
symbols = {error = '', warn = '', info = ''},
color_error = colors.red,
color_warn = colors.yellow,
color_info = 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}
ins_left {
'filename',
condition = conditions.buffer_not_empty,
color = {fg = colors.magenta, gui = 'bold'}
}
-- Add components to right sections -- Add components to right sections
ins_right { ins_right {
'o:encoding', -- option component same as &encoding in viml 'o:encoding', -- option component same as &encoding in viml
@ -209,11 +204,9 @@ ins_right {
condition = conditions.hide_in_width condition = conditions.hide_in_width
} }
ins_right { ins_right {'location'}
function() return '' end,
color = {fg = colors.blue}, ins_right {'progress', color = {fg = colors.fg, gui = 'bold'}}
right_padding = 0
}
-- Now don't forget to initialize lualine -- Now don't forget to initialize lualine
lualine.setup(config) lualine.setup(config)