2022-10-01 11:46:18 +00:00
|
|
|
local status_ok, lualine = pcall(require, "lualine")
|
|
|
|
if not status_ok then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local hide_in_width = function()
|
|
|
|
return vim.fn.winwidth(0) > 80
|
|
|
|
end
|
|
|
|
|
|
|
|
local diagnostics = {
|
|
|
|
"diagnostics",
|
|
|
|
sources = { "nvim_diagnostic" },
|
|
|
|
sections = { "error", "warn" },
|
2022-11-09 20:17:06 +00:00
|
|
|
symbols = { error = " ", warn = "!" },
|
2022-10-01 11:46:18 +00:00
|
|
|
colored = false,
|
2022-11-09 20:17:06 +00:00
|
|
|
always_visible = true,
|
2022-10-01 11:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
local diff = {
|
|
|
|
"diff",
|
|
|
|
colored = false,
|
2022-11-09 20:17:06 +00:00
|
|
|
symbols = { added = "+", modified = "", removed = "" },
|
2022-10-01 11:46:18 +00:00
|
|
|
cond = hide_in_width,
|
|
|
|
}
|
|
|
|
|
|
|
|
local filetype = {
|
|
|
|
"filetype",
|
2022-11-09 20:17:06 +00:00
|
|
|
colored = false,
|
2023-02-15 19:19:53 +00:00
|
|
|
separator = "",
|
2022-10-01 11:46:18 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 20:17:06 +00:00
|
|
|
local lsp_progress = {
|
|
|
|
"lsp_progress",
|
|
|
|
display_components = { "spinner" },
|
2023-03-31 18:44:46 +00:00
|
|
|
spinner_symbols = { "⣷", "⣯", "⣟", "⡿", "⢿", "⣻", "⣽", "⣾" },
|
2022-10-01 11:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
local spaces = function()
|
2022-10-02 10:04:24 +00:00
|
|
|
local expandtab = vim.api.nvim_buf_get_option(0, "expandtab")
|
|
|
|
|
|
|
|
local title = "spaces: "
|
|
|
|
if not expandtab then
|
|
|
|
title = "tab: "
|
|
|
|
end
|
|
|
|
|
|
|
|
return title .. vim.api.nvim_buf_get_option(0, "shiftwidth")
|
2022-10-01 11:46:18 +00:00
|
|
|
end
|
|
|
|
|
2022-10-08 12:57:06 +00:00
|
|
|
local venv = function()
|
|
|
|
local venv = os.getenv("VIRTUAL_ENV")
|
|
|
|
if venv then
|
2022-11-06 19:34:46 +00:00
|
|
|
return string.format(" %s", string.match(venv, "[^/]+$"))
|
2022-10-08 12:57:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
|
2023-02-15 19:19:53 +00:00
|
|
|
local get_schema = function()
|
|
|
|
local ft = vim.bo.filetype or ""
|
|
|
|
|
|
|
|
if ft == "yaml" then
|
|
|
|
local schema = require("yaml-companion").get_buf_schema(0)
|
|
|
|
if schema.result[1].name == "none" then
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
|
|
|
|
return "(" .. schema.result[1].name .. ")"
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-01 11:46:18 +00:00
|
|
|
local gitblame_status_ok, gitblame = pcall(require, "gitblame")
|
|
|
|
if not gitblame_status_ok then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.g.gitblame_date_format = "%r"
|
|
|
|
vim.g.gitblame_display_virtual_text = 0
|
|
|
|
vim.g.gitblame_message_template = "<author>, <date>"
|
|
|
|
|
|
|
|
lualine.setup({
|
|
|
|
options = {
|
|
|
|
globalstatus = true,
|
|
|
|
},
|
|
|
|
sections = {
|
|
|
|
lualine_a = { "mode" },
|
2022-11-06 19:34:46 +00:00
|
|
|
lualine_b = { "branch", venv },
|
2022-12-23 17:28:37 +00:00
|
|
|
lualine_c = { diagnostics, { "filename", path = 1 }, "searchcount", lsp_progress },
|
2022-10-01 11:46:18 +00:00
|
|
|
lualine_x = {
|
|
|
|
{ gitblame.get_current_blame_text, cond = gitblame.is_blame_text_available },
|
|
|
|
diff,
|
|
|
|
spaces,
|
|
|
|
"encoding",
|
|
|
|
filetype,
|
2023-02-15 19:19:53 +00:00
|
|
|
{ get_schema, separator = "" },
|
2022-10-01 11:46:18 +00:00
|
|
|
},
|
2022-11-09 20:17:06 +00:00
|
|
|
lualine_y = { "progress" },
|
|
|
|
lualine_z = { "location" },
|
2022-10-01 11:46:18 +00:00
|
|
|
},
|
|
|
|
})
|