style(nvim): format statusline.lua

This commit is contained in:
Price Hiller 2022-10-07 12:38:31 -05:00
parent 5b00b9f321
commit 8fbe4e92be

View File

@ -1,4 +1,4 @@
local present, lualine = pcall(require, 'lualine')
local present, lualine = pcall(require, "lualine")
if not present then
return
end
@ -6,48 +6,48 @@ end
-- 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)))
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)
return string.gsub(str, "%w+", "%1" .. "/%%L", 1)
end
-- For progress, add a fancy icon
local function customProgress(str)
return '' .. 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')
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 .. ']'
local size = require("lualine.components.filesize")()
return size == "" and str or str .. " [" .. size .. "]"
end
local function show_macro_recording()
local recording_register = vim.fn.reg_recording()
if recording_register == '' then
return ''
if recording_register == "" then
return ""
else
return 'Recording @' .. recording_register
return "Recording @" .. recording_register
end
end
lualine.setup({
options = {
icons_enabled = true,
theme = 'auto',
theme = "auto",
-- component_separators = { left = '', right = '' },
-- section_separators = { left = '', right = '' },
-- 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, -- requires neovim 0.7 or highter
@ -56,40 +56,39 @@ lualine.setup({
-- Left
lualine_a = {
{
'mode',
"mode",
fmt = simplifiedMode,
},
},
lualine_b = {
{
'branch',
icon = '',
"branch",
icon = "",
},
{
'diff',
symbols = { added = '+', modified = '~', removed = '-' },
"diff",
symbols = { added = "+", modified = "~", removed = "-" },
-- symbols = { added = ' ', modified = ' ', removed = ' ' },
},
{
'diagnostics',
sources = { 'nvim_diagnostic' },
"diagnostics",
sources = { "nvim_diagnostic" },
-- symbols = { error = ' ', warn = ' ', info = ' ', hint = ' ' },
symbols = { error = '', warn = '', info = '', hint = '' },
symbols = { error = "", warn = "", info = "", hint = "" },
},
{
show_macro_recording,
"macro-recording",
fmt = show_macro_recording,
},
},
lualine_c = {
{
'filename',
"filename",
path = 3,
symbols = {
modified = '[+]',
readonly = '[]',
unnamed = '[No Name]',
modified = "[+]",
readonly = "[]",
unnamed = "[No Name]",
},
fmt = fileNameAndSize,
},
@ -97,19 +96,19 @@ lualine.setup({
-- Right
lualine_x = {
'encoding',
'fileformat',
'filetype',
"encoding",
"fileformat",
"filetype",
},
lualine_y = {
{
'location',
"location",
fmt = customLocation,
},
},
lualine_z = {
{
'progress',
"progress",
fmt = customProgress,
},
},
@ -117,10 +116,10 @@ lualine.setup({
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_c = { "filename" },
lualine_x = {
{
'location',
"location",
fmt = customLocation,
},
},
@ -129,12 +128,12 @@ lualine.setup({
},
tabline = {},
extensions = {
'aerial',
'fugitive',
'nvim-tree',
'neo-tree',
'quickfix',
'toggleterm',
"aerial",
"fugitive",
"nvim-tree",
"neo-tree",
"quickfix",
"toggleterm",
},
})