Clean up lualine
This commit is contained in:
@@ -16,71 +16,10 @@
|
||||
|
||||
-- https://github.com/nvim-lualine/lualine.nvim
|
||||
|
||||
--- @param trunc_width number trunctates component when screen width is less then trunc_width
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param hide_width number hides component when window width is smaller then hide_width
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at end after truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function trunc(trunc_width, trunc_len, hide_width, no_ellipsis)
|
||||
return function (str)
|
||||
local win_width = vim.fn.winwidth(0)
|
||||
if hide_width and win_width < hide_width then
|
||||
return ""
|
||||
elseif trunc_width and trunc_len and win_width < trunc_width and #str > trunc_len then
|
||||
return str:sub(1, trunc_len) .. (no_ellipsis and "" or "...")
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at start before truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function l_trunc(trunc_len, no_ellipsis)
|
||||
return function (str)
|
||||
if #str > trunc_len then
|
||||
return (no_ellipsis and "" or "...") .. str:sub(-trunc_len, -1)
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at start before truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function r_trunc(trunc_len, no_ellipsis)
|
||||
return function (str)
|
||||
if #str > trunc_len then
|
||||
return str:sub(1, trunc_len) .. (no_ellipsis and "" or "...")
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function short_path(len)
|
||||
return function (str)
|
||||
if #str > len then
|
||||
return vim.fn.pathshorten(str, 1)
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function header()
|
||||
local text = short_path(40)(vim.fn.getcwd())
|
||||
local branch = r_trunc(15, false)(vim.fn.FugitiveHead())
|
||||
if branch ~= "" then
|
||||
text = text .. " " .. branch
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
-- theme = require('config.nightfox_lualine_custom'),
|
||||
theme = "auto",
|
||||
-- theme = "catppuccin",
|
||||
component_separators = { left = "", right = "", },
|
||||
section_separators = { left = "", right = "", },
|
||||
disabled_filetypes = { "NvimTree", "fugitive", },
|
||||
@@ -103,13 +42,4 @@ require("lualine").setup({
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
-- tabline = {
|
||||
-- lualine_a = { { header } },
|
||||
-- lualine_b = { {'tabs', mode = 0 } },
|
||||
-- lualine_c = { { 'buffers', show_filename_only = true, filetype_names = { TelescopePrompt = 'Telescope', fugitive = 'Fugitive' } } },
|
||||
-- lualine_x = {},
|
||||
-- lualine_y = {},
|
||||
-- lualine_z = {}
|
||||
-- },
|
||||
extensions = {},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user