2022-02-28 03:11:17 +00:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.config()
|
2022-09-27 17:02:49 +00:00
|
|
|
local status_lualine_ok, lualine = pcall(require, "lualine")
|
|
|
|
if not status_lualine_ok then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-09-30 17:58:04 +00:00
|
|
|
local status_gitblame_ok, gitblame = pcall(require, "gitblame")
|
2022-09-27 17:02:49 +00:00
|
|
|
if not status_gitblame_ok then
|
2022-02-28 03:11:17 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local scolors = {
|
|
|
|
fg = '#adb0b9',
|
2022-09-30 17:58:04 +00:00
|
|
|
fg_wash = '#808289',
|
2022-03-01 00:41:08 +00:00
|
|
|
bg = '#252526',
|
2022-02-28 03:11:17 +00:00
|
|
|
inset = '#569cd6',
|
|
|
|
|
2022-10-10 20:58:32 +00:00
|
|
|
working_dir = '#569cd6',
|
2022-09-30 17:58:04 +00:00
|
|
|
branch = '#dcdcaa',
|
|
|
|
filetype = '#c5a6c0',
|
2022-02-28 05:11:19 +00:00
|
|
|
filename = '#91bde1',
|
2022-02-28 03:11:17 +00:00
|
|
|
|
|
|
|
added = '#6a9955',
|
|
|
|
modified = '#db812e',
|
2022-02-28 05:11:19 +00:00
|
|
|
removed = '#f6635a',
|
|
|
|
|
|
|
|
error = '#f53226',
|
|
|
|
warn = '#eed94e',
|
|
|
|
info = '#569cd6',
|
2022-02-28 03:11:17 +00:00
|
|
|
|
|
|
|
treesitter = '#6a9955',
|
|
|
|
|
|
|
|
scroll = '#dcdcaa',
|
|
|
|
}
|
|
|
|
|
|
|
|
local conditions = {
|
2022-09-30 17:58:04 +00:00
|
|
|
buffer_not_empty = function() return vim.fn.empty(vim.fn.expand "%:t") ~= 1
|
2022-02-28 03:11:17 +00:00
|
|
|
end,
|
|
|
|
hide_in_width = function()
|
|
|
|
return vim.fn.winwidth(0) > 80
|
|
|
|
end,
|
|
|
|
check_git_workspace = function()
|
|
|
|
local filepath = vim.fn.expand "%:p:h"
|
|
|
|
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
|
|
|
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
local config = {
|
|
|
|
options = {
|
|
|
|
disabled_filetypes = { "NvimTree", "dashboard", "Outline" },
|
|
|
|
component_separators = "",
|
|
|
|
section_separators = "",
|
|
|
|
theme = {
|
|
|
|
normal = { c = { fg = scolors.fg, bg = scolors.bg } },
|
|
|
|
inactive = { c = { fg = scolors.fg, bg = scolors.bg } },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sections = {
|
|
|
|
lualine_a = {},
|
|
|
|
lualine_b = {},
|
2022-09-27 16:53:03 +00:00
|
|
|
lualine_c = {
|
2022-10-10 20:58:32 +00:00
|
|
|
{ -- 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="",
|
2022-10-06 03:48:07 +00:00
|
|
|
padding = { left = 2, right = 1 },
|
2022-09-30 17:58:04 +00:00
|
|
|
},
|
|
|
|
{ -- file name
|
|
|
|
"filename",
|
2022-10-10 20:58:32 +00:00
|
|
|
icon="",
|
2022-09-30 17:58:04 +00:00
|
|
|
color = { fg = scolors.filename, gui = "bold" },
|
|
|
|
padding = { left = 1, right = 1 },
|
|
|
|
},
|
2022-10-10 16:32:55 +00:00
|
|
|
{ -- git branch
|
|
|
|
"branch",
|
|
|
|
icon = "",
|
|
|
|
color = { fg = scolors.branch, gui = "bold" },
|
|
|
|
padding = { left = 1, right = 1 },
|
|
|
|
},
|
2022-10-10 20:58:32 +00:00
|
|
|
{ -- filetype
|
|
|
|
"filetype",
|
|
|
|
colored = false,
|
|
|
|
color = { fg = scolors.filetype, gui = "bold" },
|
|
|
|
cond = conditions.buffer_not_empty,
|
|
|
|
padding = { left = 1, right = 1 },
|
2022-10-10 16:32:55 +00:00
|
|
|
},
|
2022-09-30 17:58:04 +00:00
|
|
|
{ -- 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 },
|
|
|
|
},
|
2022-10-06 04:18:15 +00:00
|
|
|
padding = { left = 1, right = 1 },
|
2022-09-30 17:58:04 +00:00
|
|
|
},
|
|
|
|
},
|
2022-09-27 16:53:03 +00:00
|
|
|
lualine_x = {
|
2022-09-30 17:58:04 +00:00
|
|
|
{ -- git blame
|
|
|
|
gitblame.get_current_blame_text,
|
|
|
|
color = { fg = scolors.fg_wash },
|
|
|
|
cond = gitblame.is_blame_text_available,
|
|
|
|
padding = { left = 0, right = 1 },
|
|
|
|
},
|
|
|
|
{ -- 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 },
|
|
|
|
},
|
|
|
|
},
|
2022-02-28 03:11:17 +00:00
|
|
|
lualine_y = {},
|
|
|
|
lualine_z = {},
|
|
|
|
},
|
|
|
|
inactive_sections = {
|
2022-10-10 20:58:32 +00:00
|
|
|
lualine_a = {
|
2022-10-06 03:48:07 +00:00
|
|
|
{ -- file name
|
|
|
|
"filename",
|
2022-10-10 20:58:32 +00:00
|
|
|
icon="",
|
2022-10-06 03:48:07 +00:00
|
|
|
color = { fg = scolors.filename, gui = "bold" },
|
|
|
|
padding = { left = 1, right = 1 },
|
|
|
|
},
|
2022-10-10 20:58:32 +00:00
|
|
|
},
|
|
|
|
lualine_b = {},
|
|
|
|
lualine_c = {},
|
|
|
|
lualine_x = {},
|
2022-09-27 16:53:03 +00:00
|
|
|
lualine_y = {},
|
|
|
|
lualine_z = {},
|
2022-10-06 03:48:07 +00:00
|
|
|
}
|
2022-02-28 03:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lualine.setup(config)
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|
|
|
|
|