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