lualine working directory

This commit is contained in:
Michael Peters 2022-10-10 13:58:32 -07:00
parent 5abd75b202
commit e74618efd4

View File

@ -17,6 +17,7 @@ function M.config()
bg = '#252526',
inset = '#569cd6',
working_dir = '#569cd6',
branch = '#dcdcaa',
filetype = '#c5a6c0',
filename = '#91bde1',
@ -61,15 +62,20 @@ function M.config()
lualine_a = {},
lualine_b = {},
lualine_c = {
{ -- filetype
"filetype",
colored = false,
color = { fg = scolors.filetype, gui = "bold" },
cond = conditions.buffer_not_empty,
{ -- working dir
function ()
local cwd = vim.fn.getcwd()
-- substr the cwd starting at the last "/" character
local cwd_name = string.sub(cwd,-cwd:reverse():find("/")+1)
return cwd_name
end,
color = { fg = scolors.working_dir, gui = "bold" },
icon="",
padding = { left = 2, right = 1 },
},
{ -- file name
"filename",
icon="",
color = { fg = scolors.filename, gui = "bold" },
padding = { left = 1, right = 1 },
},
@ -79,10 +85,12 @@ function M.config()
color = { fg = scolors.branch, gui = "bold" },
padding = { left = 1, right = 1 },
},
{ -- working dir
function () return vim.fn.getcwd() end,
color = { fg = scolors.branch, gui = "bold" },
padding = { left = 0, right = 1 },
{ -- filetype
"filetype",
colored = false,
color = { fg = scolors.filetype, gui = "bold" },
cond = conditions.buffer_not_empty,
padding = { left = 1, right = 1 },
},
{ -- git diff
"diff",
@ -142,74 +150,17 @@ function M.config()
lualine_z = {},
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
{ -- filetype
"filetype",
colored = false,
color = { fg = scolors.filetype, gui = "bold" },
cond = conditions.buffer_not_empty,
padding = { left = 2, right = 1 },
},
lualine_a = {
{ -- file name
"filename",
icon="",
color = { fg = scolors.filename, gui = "bold" },
padding = { left = 1, right = 1 },
},
{ -- git diff
"diff",
symbols = { added = "", modified = "", removed = "" },
diff_color = {
added = { fg = scolors.added },
modified = { fg = scolors.modified },
removed = { fg = scolors.removed },
},
cond = conditions.hide_in_width,
padding = { left = 1, right = 1 },
},
{ -- nvim diagnostics
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = { error = "", warn = "", info = "", hint = "" },
diagnostics_color = {
color_error = { fg = scolors.error },
color_warn = { fg = scolors.warn },
color_info = { fg = scolors.info },
},
padding = { left = 1, right = 1 },
},
{ -- git branch
"branch",
icon = "",
padding = { left = 1, right = 1 },
},
},
lualine_x = {
{ -- location in file (line:col)
"location",
padding = { left = 0, right = 1 },
},
{ -- progress through file (%)
-- slightly modified from default "progress"
-- always 3 chars long, no TOP
-- https://github.com/nvim-lualine/lualine.nvim/blob/master/lua/lualine/components/progress.lua
function ()
local cur = vim.fn.line('.')
local total = vim.fn.line('$')
if cur == total then
return 'BOT'
elseif cur / total < 0.10 then
return ' ' .. math.floor(cur / total * 100) .. '%%'
else
return math.floor(cur / total * 100) .. '%%'
end
end,
"progress",
color = { gui = "none" },
padding = { left = 0, right = 1 },
},
},
},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
}