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
|
|
|
|
|
2022-03-26 19:37:50 +00:00
|
|
|
local theme = require("statusline.themes.tokyonight")
|
2022-03-26 17:17:28 +00:00
|
|
|
|
2022-03-26 19:37:50 +00:00
|
|
|
local ns = vim.api.nvim_create_namespace("statusline")
|
2022-03-26 17:17:28 +00:00
|
|
|
|
2022-03-26 19:37:50 +00:00
|
|
|
function M.output()
|
2022-10-06 23:21:41 +01:00
|
|
|
vim.api.nvim_set_hl_ns(ns)
|
2022-03-26 17:17:28 +00:00
|
|
|
|
2022-03-26 19:37:50 +00:00
|
|
|
for name, settings in pairs(theme.theme) do
|
2022-03-26 17:17:28 +00:00
|
|
|
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{
|
2022-03-26 19:37:50 +00:00
|
|
|
setHighlight(theme.statuslineMode),
|
2022-03-13 15:35:55 +00:00
|
|
|
mode,
|
2022-03-26 17:17:28 +00:00
|
|
|
separator,
|
2022-03-26 19:37:50 +00:00
|
|
|
setHighlight(theme.statuslineBlueText),
|
2022-03-13 15:35:55 +00:00
|
|
|
open_file,
|
|
|
|
buf_nr,
|
2022-03-26 17:47:10 +00:00
|
|
|
separator,
|
2022-03-26 19:37:50 +00:00
|
|
|
setHighlight(theme.statuslineTransparent),
|
2022-03-13 15:35:55 +00:00
|
|
|
right_align,
|
2022-03-26 19:37:50 +00:00
|
|
|
setHighlight(theme.statuslineBlueText),
|
2022-03-13 15:35:55 +00:00
|
|
|
separator,
|
|
|
|
file_format,
|
|
|
|
file_type,
|
|
|
|
encoding,
|
2022-03-26 19:37:50 +00:00
|
|
|
setHighlight(theme.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
|