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
component_separators = "",
section_separators = "",
-- theme = 'gruvbox',
theme = {
-- 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
normal = {c = {fg = colors.fg, bg = colors.bg}},
inactive = {c = {fg = colors.fg, bg = colors.bg}}
@ -48,7 +49,7 @@ local config = {
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
-- these will be filled later
lualine_c = {},
lualine_x = {}
},
@ -63,57 +64,56 @@ 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)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x ot right section
-- inserts a component in lualine_x ot right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function() return '' end,
color = {fg = colors.blue}, -- Sets highlighting of component
left_padding = 0 -- We don't need space before this
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
}
ins_left {
-- mode component
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
}
vim.api.nvim_command(
'hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. " guibg=" ..
colors.bg)
'hi! lualinemode guifg=' .. mode_color[vim.fn.mode()] .. " guibg=" .. colors.bg)
return ''
end,
color = "LualineMode",
color = "lualinemode",
left_padding = 0
}
ins_left {
"mode",
color = {fg = colors.green, gui = 'bold'}
}
ins_left {
-- filesize component
function()
@ -134,30 +134,6 @@ ins_left {
end,
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 {
-- Lsp server name .
function()
@ -177,6 +153,25 @@ ins_left {
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
ins_right {
'o:encoding', -- option component same as &encoding in viml
@ -209,11 +204,9 @@ ins_right {
condition = conditions.hide_in_width
}
ins_right {
function() return '' end,
color = {fg = colors.blue},
right_padding = 0
}
ins_right {'location'}
ins_right {'progress', color = {fg = colors.fg, gui = 'bold'}}
-- Now don't forget to initialize lualine
lualine.setup(config)