nvim: better statusline

This commit is contained in:
Price Hiller 2022-06-04 21:25:49 -05:00
parent 0a0f43438b
commit a6074af24f

View File

@ -3,41 +3,125 @@ if not present then
return
end
local left_pad = ''
local right_pad = ''
-- Thanks to rockyzhang24 (github.com/rockyzhang24)
local function simplifiedMode(str)
return '' .. (str == 'V-LINE' and 'VL' or (str == 'V-BLOCK' and 'VB' or str:sub(1, 1)))
end
-- For location, show total lines
local function customLocation(str)
return string.gsub(str, '%w+', '%1' .. '/%%L', 1)
end
-- For progress, add a fancy icon
local function customProgress(str)
return '' .. str
end
-- For filename, show the filename and the filesize
local function fileNameAndSize(str)
-- For doc, only show filename
if string.find(str, '.*/doc/.*%.txt') then
str = vim.fn.expand('%:t')
end
local size = require('lualine.components.filesize')()
return size == '' and str or str .. ' [' .. size .. ']'
end
lualine.setup({
options = {
icons_enabled = true,
theme = 'auto',
component_separators = '|',
section_separators = { left = left_pad, right = right_pad },
-- component_separators = { left = '', right = '' },
-- section_separators = { left = '', right = '' },
-- component_separators = { left = '', right = '' },
-- section_separators = { left = '', right = '' },
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
globalstatus = true,
globalstatus = true, -- requires neovim 0.7 or highter
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
-- Left
lualine_a = {
{
'mode',
fmt = simplifiedMode,
},
},
lualine_b = {
{
'branch',
icon = '',
},
{
'diff',
symbols = { added = '+', modified = '~', removed = '-' },
-- symbols = { added = ' ', modified = ' ', removed = ' ' },
},
{
'diagnostics',
sources = { 'nvim_diagnostic' },
-- symbols = { error = ' ', warn = ' ', info = ' ', hint = ' ' },
symbols = { error = '', warn = '', info = '', hint = '' },
},
},
lualine_c = {
{
'filename',
file_status = true,
path = 1,
path = 3,
symbols = {
modified = '[+]',
readonly = '[]',
unnamed = '[No Name]',
},
fmt = fileNameAndSize,
},
},
-- Right
lualine_x = {
'progress',
'encoding',
'fileformat',
'filetype',
},
lualine_y = {
{
'location',
fmt = customLocation,
},
},
lualine_z = {
{
'progress',
fmt = customProgress,
},
},
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_x = {
{
'location',
fmt = customLocation,
},
},
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = { 'fugitive', 'fzf' },
extensions = {
'aerial',
'fugitive',
'nvim-tree',
'neo-tree',
'quickfix',
'toggleterm',
},
})