More StatusLine Improvements

main
zoomiti 4 months ago
parent 2369fb36e8
commit 3fc2cc16d1

@ -355,12 +355,13 @@ local statusline = {
'%{v:lua.StatuslineMode()}', '%{v:lua.StatuslineMode()}',
'%{%v:lua.StatuslineHighlight("Secondary")%}', '%{%v:lua.StatuslineHighlight("Secondary")%}',
'%{v:lua.StatuslineBranch()}', '%{v:lua.StatuslineBranch()}',
' %{v:lua.StatuslineFilename()} ', '%{%v:lua.StatuslineFilename()%} ',
'%(',
'%{%v:lua.StatuslineReadOnly()%}', '%{%v:lua.StatuslineReadOnly()%}',
'%{%v:lua.StatuslineModified()%}', '%{%v:lua.StatuslineModified()%}',
'%)',
'%{%v:lua.StatuslineHighlight("Middle")%}', '%{%v:lua.StatuslineHighlight("Middle")%}',
'%=', '%=',
' ',
'%{&ff}', -- File Format '%{&ff}', -- File Format
' | ', ' | ',
'%{&fenc!=#""?&fenc:&enc}', -- File Encoding '%{&fenc!=#""?&fenc:&enc}', -- File Encoding
@ -453,8 +454,6 @@ local mode_map_hi = {
['t'] = 'TERMINAL', ['t'] = 'TERMINAL',
} }
local fmt = string.format
local highlights = { local highlights = {
["NORMAL"] = { ["NORMAL"] = {
["Left"] = { fg = "#c8c6c5", bg = "#2e2828", bold = true, }, ["Left"] = { fg = "#c8c6c5", bg = "#2e2828", bold = true, },
@ -494,19 +493,16 @@ for mode, colors in pairs(highlights) do
end end
end end
function StatuslineHighlight(part) function StatuslineHighlight(part)
local mode = vim.api.nvim_get_mode().mode local mode = vim.api.nvim_get_mode().mode
local mode_name = mode_map_hi[mode] or mode local mode_name = mode_map_hi[mode] or mode
return fmt('%%#StatusLine_%s_%s#', mode_name, part) return '%#StatusLine_' .. mode_name .. '_' .. part .. '#'
end end
function StatuslineMode() function StatuslineMode()
local mode = vim.api.nvim_get_mode().mode local mode = vim.api.nvim_get_mode().mode
local mode_name = mode_map[mode] or mode local mode_name = mode_map[mode] or mode
return fmt(' %s ', mode_name) return ' ' .. mode_name .. ' '
end end
function SpecialBuffer() function SpecialBuffer()
@ -519,23 +515,19 @@ function StatuslineReadOnly()
end end
function StatuslineModified() function StatuslineModified()
if vim.b.modifiable then return vim.bo.modifiable and '%m ' or ''
return '%m'
else
return ''
end
end end
function StatuslineBranch() function StatuslineBranch()
local head = vim.b.gitsigns_head local head = vim.b.gitsigns_head
return SpecialBuffer() ~= true and head ~= nil and fmt(' git(%s) |', head) or '' return SpecialBuffer() ~= true and head ~= nil and ' git(' .. head .. ') | ' or ''
end end
function StatuslineFilename() function StatuslineFilename()
local special_files = { local special_files = {
['help'] = " Help", ['help'] = " Help",
['qf'] = '[QuickFix] ' .. (vim.w.quickfix_title or ""), ['qf'] = ' %q ' .. (vim.w.quickfix_title or ""),
['NeogitStatus'] = vim.b.gitsigns_head ['NeogitStatus'] = ' ' .. (vim.b.gitsigns_head or "")
} }
local filename = vim.fn.expand('%:t') local filename = vim.fn.expand('%:t')

Loading…