diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua index a383585..7bd8386 100644 --- a/.config/nvim/lua/statusline.lua +++ b/.config/nvim/lua/statusline.lua @@ -113,7 +113,11 @@ local function shorten_path(path, max_len) end local segment = segments[idx] - local shortened = segment:sub(1, vim.startswith(segment, '.') and 2 or 1) + local short_end = 1 + if (vim.startswith(segment, '.') or vim.startswith(segment, '_')) then + short_end = 2 + end + local shortened = segment:sub(1, short_end) segments[idx] = shortened len = len - (#segment - #shortened) end @@ -169,49 +173,48 @@ local function statusline_focused() local winwidth = vim.fn.winwidth(0) local left = table.concat { - gen_section(accent_color, { get_mode_display_name(mg) }), - gen_section("%#Middle#", { shorten_path(file, winwidth / 3) }), - gen_section("%#Bottom#", { "%m", "%r" }), - gen_section( - "%#Alert#", - { - process_diagnostics( - globals.sign_error .. " ", - diagnostics.error, - "%#DiagnosticVirtualTextError#" - ), - process_diagnostics( - globals.sign_warn .. " ", - diagnostics.warn, - "%#DiagnosticVirtualTextWarn#" - ), - process_diagnostics( - globals.sign_info .. " ", - diagnostics.info, - "%#DiagnosticVirtualTextInfo#" - ) - } - ) - } + gen_section(accent_color, { get_mode_display_name(mg) }), + gen_section("%#Middle#", { shorten_path(file, winwidth / 3) }), + gen_section("%#Bottom#", { "%m", "%r" }), + gen_section( + "%#Alert#", + { + process_diagnostics( + globals.sign_error .. " ", + diagnostics.error, + "%#DiagnosticVirtualTextError#" + ), + process_diagnostics( + globals.sign_warn .. " ", + diagnostics.warn, + "%#DiagnosticVirtualTextWarn#" + ), + process_diagnostics( + globals.sign_info .. " ", + diagnostics.info, + "%#DiagnosticVirtualTextInfo#" + ) + } + ) + } local right = table.concat { - gen_section( - "%#Bottom#", - { - spell_check(), - vim.bo.filetype - } - ), - gen_section("%#Middle#", { "%03.p%%" }), - gen_section("%#Top#", { "-%03.c-" }) - } + gen_section( + "%#Bottom#", + { + spell_check(), + vim.bo.filetype + } + ), + gen_section("%#Middle#", { "%03.p%%" }), + gen_section("%#Top#", { "-%03.c-" }) + } return table.concat { - left, - "%#Statusline#", - "%=", - right - } - + left, + "%#Statusline#", + "%=", + right + } end local function statusline_not_focused() @@ -219,14 +222,14 @@ local function statusline_not_focused() local file = vim.fn.expand("#" .. bufnr .. ":p:~") local winwidth = vim.fn.winwidth(0) return table.concat { - gen_section("%#StatuslineNF#", { - shorten_path(file, winwidth / 3), - "%m" - }), - "%=", - gen_section("%#StatuslineNF#", { "%03.p%%" }), - gen_section("%#StatuslineNF#", { "-%03.c-" }) - } + gen_section("%#StatuslineNF#", { + shorten_path(file, winwidth / 3), + "%m" + }), + "%=", + gen_section("%#StatuslineNF#", { "%03.p%%" }), + gen_section("%#StatuslineNF#", { "-%03.c-" }) + } end function _G.gen_statusline()