2021-08-25 23:21:50 +00:00
|
|
|
|
local M = {}
|
2021-12-09 06:13:53 +00:00
|
|
|
|
local utils = require("utils")
|
2021-08-25 23:21:50 +00:00
|
|
|
|
|
|
|
|
|
-- Only return interesting ffenc (not utf-8[unix])
|
|
|
|
|
function M.custom_ffenc()
|
|
|
|
|
local enc = vim.bo.fenc
|
|
|
|
|
local format = vim.bo.fileformat
|
|
|
|
|
if enc ~= "utf-8" or format ~= "unix" then
|
|
|
|
|
return enc .. "[" .. format .. "]"
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-21 17:24:28 +00:00
|
|
|
|
return ""
|
2021-08-25 23:21:50 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.mixed_indent()
|
2021-12-15 17:37:51 +00:00
|
|
|
|
local mixed = vim.fn.search([[\v^(\t+ | +\t)]], "nw")
|
2021-08-25 23:21:50 +00:00
|
|
|
|
if mixed > 0 then
|
|
|
|
|
return "i:" .. mixed
|
|
|
|
|
end
|
2021-12-15 17:37:51 +00:00
|
|
|
|
local space_indent = vim.fn.search([[\v^ +]], "nw")
|
|
|
|
|
local tab_indent = vim.fn.search([[\v^\t+]], "nw")
|
2021-08-25 23:21:50 +00:00
|
|
|
|
if tab_indent > 0 and space_indent > 0 then
|
|
|
|
|
return "i:" .. require("math").max(tab_indent, space_indent)
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-21 17:24:28 +00:00
|
|
|
|
return ""
|
2021-08-25 23:21:50 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M.trailing_whitespace()
|
2021-12-15 17:37:51 +00:00
|
|
|
|
local line = vim.fn.search([[\s\+$]], "nw")
|
2021-09-01 17:03:05 +00:00
|
|
|
|
if line ~= 0 then
|
|
|
|
|
return "tw:" .. line
|
2021-08-25 23:21:50 +00:00
|
|
|
|
end
|
|
|
|
|
|
2021-10-21 17:24:28 +00:00
|
|
|
|
return ""
|
2021-08-25 23:21:50 +00:00
|
|
|
|
end
|
|
|
|
|
|
2023-06-26 21:48:39 +00:00
|
|
|
|
-- Plugin to print name of current CSV column
|
|
|
|
|
M.csv_col = {
|
|
|
|
|
function()
|
|
|
|
|
return vim.fn.CSVCol(1)
|
|
|
|
|
end,
|
|
|
|
|
cond = function()
|
|
|
|
|
return vim.bo.filetype == "csv" and vim.fn.exists("*CSVCol") == 1
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-25 23:21:50 +00:00
|
|
|
|
-- Configure lualine witha provided theme
|
|
|
|
|
function M.config_lualine(theme_name)
|
2021-09-01 17:03:05 +00:00
|
|
|
|
-- Theme name transformations
|
2021-08-25 23:21:50 +00:00
|
|
|
|
if theme_name == nil then
|
|
|
|
|
theme_name = "auto"
|
2021-09-28 01:00:17 +00:00
|
|
|
|
elseif theme_name:find("wombat") then
|
2021-08-25 23:21:50 +00:00
|
|
|
|
theme_name = "wombat"
|
2021-09-01 17:03:05 +00:00
|
|
|
|
elseif theme_name == "wombuddy" then
|
|
|
|
|
theme_name = "wombat"
|
2021-08-25 23:21:50 +00:00
|
|
|
|
end
|
|
|
|
|
|
2024-05-29 20:16:28 +00:00
|
|
|
|
-- navic
|
2023-06-02 00:11:50 +00:00
|
|
|
|
local code_loc = {}
|
|
|
|
|
utils.try_require("nvim-navic", function(navic)
|
2023-06-12 19:31:15 +00:00
|
|
|
|
navic.setup({
|
|
|
|
|
icons = {
|
2024-07-18 18:20:46 +00:00
|
|
|
|
Array = "𝐴 ",
|
|
|
|
|
Boolean = "𝐵 ",
|
|
|
|
|
Class = "ℂ ",
|
|
|
|
|
Constant = "ℭ ",
|
|
|
|
|
Constructor = "𝕮 ",
|
|
|
|
|
Enum = "𝐸 ",
|
|
|
|
|
EnumMember = "𝐸𝑀 ",
|
|
|
|
|
Event = "𝐸 ",
|
|
|
|
|
Field = "𝐹 ",
|
|
|
|
|
File = "📄 ",
|
|
|
|
|
Function = "𝑓 ",
|
|
|
|
|
Interface = "𝐼 ",
|
|
|
|
|
Key = "𝐾 ",
|
|
|
|
|
Method = "m ",
|
|
|
|
|
Module = "𝑀 ",
|
|
|
|
|
Namespace = "𝑁 ",
|
|
|
|
|
Null = "𝑁 ",
|
|
|
|
|
Number = "𝑁 ",
|
|
|
|
|
Object = "𝑂 ",
|
|
|
|
|
Operator = "𝑂 ",
|
|
|
|
|
Package = "📦 ",
|
|
|
|
|
Property = "𝑃 ",
|
|
|
|
|
String = "𝑆 ",
|
|
|
|
|
Struct = "𝑆 ",
|
|
|
|
|
TypeParameter = "𝑇𝑃 ",
|
|
|
|
|
Variable = "𝑉 ",
|
2023-06-12 19:31:15 +00:00
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
code_loc = { "navic" }
|
2023-06-02 00:11:50 +00:00
|
|
|
|
end)
|
2021-12-09 06:13:53 +00:00
|
|
|
|
|
2021-12-15 17:37:51 +00:00
|
|
|
|
require("lualine").setup({
|
2021-08-25 23:21:50 +00:00
|
|
|
|
options = {
|
|
|
|
|
theme = theme_name,
|
|
|
|
|
icons_enabled = false,
|
2021-12-15 17:37:51 +00:00
|
|
|
|
component_separators = { left = "|", right = "|" },
|
|
|
|
|
section_separators = { left = "", right = "" },
|
2021-08-25 23:21:50 +00:00
|
|
|
|
},
|
|
|
|
|
sections = {
|
2021-12-15 17:37:51 +00:00
|
|
|
|
lualine_a = {
|
|
|
|
|
{
|
|
|
|
|
"mode",
|
|
|
|
|
fmt = function(str)
|
|
|
|
|
return str:sub(1, 1)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-12-15 00:20:07 +00:00
|
|
|
|
lualine_b = { "FugitiveHead", "diff" },
|
2023-06-26 21:48:39 +00:00
|
|
|
|
lualine_c = { { "filename", path = 1 }, code_loc, M.csv_col },
|
2021-12-15 00:20:07 +00:00
|
|
|
|
lualine_x = { M.custom_ffenc, "filetype" },
|
|
|
|
|
lualine_y = { "progress", "location" },
|
2021-08-25 23:21:50 +00:00
|
|
|
|
lualine_z = {
|
2024-05-29 20:16:28 +00:00
|
|
|
|
{ "diagnostics", sources = { "nvim_diagnostic" } },
|
2021-12-15 00:20:07 +00:00
|
|
|
|
{ M.mixed_indent, color = { bg = "#de4f1f" } },
|
|
|
|
|
{ M.trailing_whitespace, color = { bg = "#de4f1f" } },
|
2021-08-25 23:21:50 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2021-12-15 17:37:51 +00:00
|
|
|
|
})
|
2021-08-25 23:21:50 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|