vim: more tweaks to lualine

1. Show the filename in italics if file is modified.
2. Put the plus sign on the right of the filename and make it stand out.
3. The symbols I was using were not rendering well on macOS and don't
   really have the time to debug this now. Just use simpler line.
This commit is contained in:
Fernando Schauenburg 2022-10-25 20:55:14 +02:00
parent 8242d356bc
commit f3a493d6f6

View file

@ -1,25 +1,25 @@
local MODE_MAP = { local MODE_MAP = {
['n'] = ' Normal', ['n'] = 'Normal ',
['no'] = ' O-Pend', ['no'] = 'O-Pend ',
['nov'] = ' O-Pend', ['nov'] = 'O-Pend ',
['noV'] = ' O-Pend', ['noV'] = 'O-Pend ',
['no'] = ' O-Pend', ['no'] = 'O-Pend ',
['niI'] = ' Normal', ['niI'] = 'Normal ',
['niR'] = ' Normal', ['niR'] = 'Normal ',
['niV'] = ' Normal', ['niV'] = 'Normal ',
['nt'] = ' Normal', ['nt'] = 'Normal ',
['v'] = ' Visual', ['v'] = 'Visual ',
['vs'] = ' Visual', ['vs'] = 'Visual ',
['V'] = ' V-Line', ['V'] = 'V-Line ',
['Vs'] = ' V-Line', ['Vs'] = 'V-Line ',
[''] = 'V-Block', [''] = 'V-Block',
['s'] = 'V-Block', ['s'] = 'V-Block',
['s'] = 'Select ', ['s'] = 'Select ',
['S'] = 'S-Line ', ['S'] = 'S-Line ',
[''] = 'S-Block', [''] = 'S-Block',
['i'] = ' Insert', ['i'] = 'Insert ',
['ic'] = ' Insert', ['ic'] = 'Insert ',
['ix'] = ' Insert', ['ix'] = 'Insert ',
['R'] = 'Replace', ['R'] = 'Replace',
['Rc'] = 'Replace', ['Rc'] = 'Replace',
['Rx'] = 'Replace', ['Rx'] = 'Replace',
@ -27,13 +27,13 @@ local MODE_MAP = {
['Rvc'] = 'V-Repl ', ['Rvc'] = 'V-Repl ',
['Rvx'] = 'V-Repl ', ['Rvx'] = 'V-Repl ',
['c'] = 'Command', ['c'] = 'Command',
['cv'] = ' Ex ', ['cv'] = 'Ex',
['ce'] = ' Ex ', ['ce'] = 'Ex',
['r'] = 'Replace', ['r'] = 'Replace',
['rm'] = ' More ', ['rm'] = 'More',
['r?'] = 'Confirm', ['r?'] = 'Confirm',
['!'] = ' Shell ', ['!'] = 'Shell',
['t'] = ' Term ', ['t'] = 'Term',
} }
local update_status = function(self, is_focused) local update_status = function(self, is_focused)
@ -68,7 +68,6 @@ local parts = {
local code = vim.api.nvim_get_mode().mode local code = vim.api.nvim_get_mode().mode
return MODE_MAP[code] or code return MODE_MAP[code] or code
end, end,
padding = 0,
}, },
visual_multi = function() visual_multi = function()
@ -80,7 +79,6 @@ local parts = {
branch = { branch = {
'branch', 'branch',
icon = '', icon = '',
padding = 0,
cond = window_is_medium, cond = window_is_medium,
}, },
@ -95,22 +93,33 @@ local parts = {
end end
return table.concat(flags, ' ') return table.concat(flags, ' ')
end, end,
padding = { left = 1, right = 0 },
color = { fg = '#eee8d5' },
}, },
filename = function() filename = {
local shorten_path = function(path) function()
if window_is_wide() then local shorten_path = function(path)
return path if window_is_wide() then
elseif window_is_medium() then return path
return vim.fn.pathshorten(path) -- only first letter of directories elseif window_is_medium() then
else return vim.fn.pathshorten(path) -- only first letter of directories
return vim.fn.fnamemodify(path, ':t') -- only tail else
return vim.fn.fnamemodify(path, ':t') -- only tail
end
end end
end
return shorten_path(vim.fn.expand('%:~:.')) return shorten_path(vim.fn.expand('%:~:.'))
end, end,
color = function()
if vim.bo.modified then
return { gui = 'italic' }
end
end,
padding = { left = 1, right = 0},
},
filetype = { filetype = {
filetype, filetype,
@ -119,7 +128,6 @@ local parts = {
fileformat = { fileformat = {
'fileformat', 'fileformat',
padding = { left = 0, right = 1 },
cond = window_is_medium, cond = window_is_medium,
}, },
@ -132,27 +140,22 @@ local parts = {
padding = { left = 0, right = 1 }, padding = { left = 0, right = 1 },
cond = window_is_wide, cond = window_is_wide,
}, },
location = {
'location',
padding = { left = 0, right = 1 },
},
} }
local inactive_sections = { local inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = { parts.visual_multi, parts.branch, parts.status }, lualine_b = { parts.visual_multi, parts.branch },
lualine_c = { parts.filename }, lualine_c = { parts.filename, parts.status },
lualine_x = { 'diagnostics', parts.filetype }, lualine_x = { 'diagnostics', parts.filetype },
lualine_y = { parts.fileformat, parts.progress }, lualine_y = { parts.fileformat, parts.progress },
lualine_z = { parts.location }, lualine_z = { 'location' },
} }
require('lualine').setup { require('lualine').setup {
options = { options = {
icons_enabled = true, icons_enabled = true,
component_separators = { left = '', right = '' }, component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' }, section_separators = { left = '', right = '' },
theme = 'solarized', theme = 'solarized',
}, },