2022-03-13 15:35:55 +00:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
local function t(str)
|
|
|
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
function _G.format_mode(mode)
|
|
|
|
local map_table = {
|
|
|
|
["n"] = "normal",
|
|
|
|
["no"] = "normal·operator pending",
|
|
|
|
["v"] = "visual",
|
|
|
|
["V"] = "visual(line)",
|
|
|
|
[t('<C-v>')] = "visual(block)",
|
|
|
|
["s"] = "select",
|
|
|
|
["S"] = "select(line)",
|
|
|
|
[t('<C-s>')] = "select(block)",
|
|
|
|
["i"] = "insert",
|
|
|
|
["R"] = "replace",
|
|
|
|
["Rv"] = "v·replace",
|
|
|
|
["c"] = "command",
|
|
|
|
["cv"] = "vim ex",
|
|
|
|
["ce"] = "ex",
|
|
|
|
["r"] = "prompt",
|
|
|
|
["rm"] = "more",
|
|
|
|
["r?"] = "confirm",
|
|
|
|
["!" ] = "shell",
|
|
|
|
["t"] = "terminal",
|
|
|
|
}
|
|
|
|
|
|
|
|
local output = map_table[mode]
|
|
|
|
|
|
|
|
if output == nil then
|
|
|
|
output = mode
|
|
|
|
end
|
|
|
|
|
2022-03-26 17:17:28 +00:00
|
|
|
return string.upper(output)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function setHighlight(str)
|
|
|
|
return string.format("%%#%s#", str)
|
2022-03-13 15:35:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.output()
|
2022-03-26 17:17:28 +00:00
|
|
|
local palette = {
|
|
|
|
cyan = "#7dcfff",
|
|
|
|
blue = "#7aa2f7",
|
|
|
|
magenta = "#bb9af7",
|
|
|
|
black = "#414868",
|
|
|
|
bg = "#15161e",
|
|
|
|
none = "NONE",
|
|
|
|
}
|
|
|
|
|
|
|
|
local statuslineMode = "StatuslineMode"
|
|
|
|
local statuslineTransparent = "StatuslineTransparent"
|
|
|
|
local statuslineBlueText = "StatuslineBlueText"
|
|
|
|
local statuslineMagentaText = "StatuslineMagentaText"
|
|
|
|
|
|
|
|
local theme = {
|
|
|
|
[statuslineMode] = {fg = palette["black"], bg = palette["cyan"], bold = true},
|
|
|
|
[statuslineTransparent] = {bg = palette["none"]},
|
|
|
|
[statuslineBlueText] = {bg = palette["bg"], fg = palette["blue"], bold = true},
|
|
|
|
[statuslineMagentaText] = {bg = palette["bg"], fg = palette["magenta"], bold = true},
|
|
|
|
}
|
|
|
|
|
|
|
|
local ns = vim.api.nvim_create_namespace("statusline")
|
|
|
|
vim.api.nvim__set_hl_ns(ns)
|
|
|
|
|
|
|
|
for name, settings in pairs(theme) do
|
|
|
|
vim.api.nvim_set_hl(ns, name, settings)
|
|
|
|
end
|
|
|
|
|
2022-03-26 17:47:10 +00:00
|
|
|
local separator = "▒▒"
|
2022-03-26 17:17:28 +00:00
|
|
|
local mode = " %{%v:lua.format_mode(v:lua.vim.fn.mode())%} "
|
2022-03-26 17:47:10 +00:00
|
|
|
local open_file = " %r%t %m"
|
2022-03-26 17:17:28 +00:00
|
|
|
local buf_nr = "[%n] "
|
2022-03-13 15:35:55 +00:00
|
|
|
local right_align = "%="
|
2022-03-26 17:47:10 +00:00
|
|
|
local file_format = " %{&ff}"
|
2022-03-26 17:17:28 +00:00
|
|
|
local file_type = "%y "
|
|
|
|
local encoding = "%{''.(&fenc!=''?&fenc:&enc).''} "
|
2022-03-26 17:47:10 +00:00
|
|
|
local line_no = " line: %03l/%03L "
|
|
|
|
local percentage = "[%3p%%] "
|
2022-03-13 15:35:55 +00:00
|
|
|
|
2022-03-26 17:17:28 +00:00
|
|
|
return table.concat{
|
|
|
|
setHighlight(statuslineMode),
|
2022-03-13 15:35:55 +00:00
|
|
|
mode,
|
2022-03-26 17:17:28 +00:00
|
|
|
setHighlight(statuslineBlueText),
|
|
|
|
separator,
|
2022-03-13 15:35:55 +00:00
|
|
|
open_file,
|
|
|
|
buf_nr,
|
2022-03-26 17:47:10 +00:00
|
|
|
separator,
|
2022-03-26 17:17:28 +00:00
|
|
|
setHighlight(statuslineTransparent),
|
2022-03-13 15:35:55 +00:00
|
|
|
right_align,
|
2022-03-26 17:17:28 +00:00
|
|
|
setHighlight(statuslineBlueText),
|
2022-03-13 15:35:55 +00:00
|
|
|
separator,
|
|
|
|
file_format,
|
|
|
|
file_type,
|
|
|
|
encoding,
|
2022-03-26 17:17:28 +00:00
|
|
|
setHighlight(statuslineMagentaText),
|
2022-03-13 15:35:55 +00:00
|
|
|
separator,
|
|
|
|
line_no,
|
2022-03-26 17:47:10 +00:00
|
|
|
percentage,
|
|
|
|
separator,
|
2022-03-26 17:17:28 +00:00
|
|
|
}
|
2022-03-13 15:35:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|