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('')] = "visual(block)", ["s"] = "select", ["S"] = "select(line)", [t('')] = "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 return string.upper(output) end local function setHighlight(str) return string.format("%%#%s#", str) end function M.output() 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 local separator = "▒▒" local mode = " %{%v:lua.format_mode(v:lua.vim.fn.mode())%} " local open_file = " %r%t %m" local buf_nr = "[%n] " local right_align = "%=" local file_format = " %{&ff}" local file_type = "%y " local encoding = "%{''.(&fenc!=''?&fenc:&enc).''} " local line_no = " line: %03l/%03L " local percentage = "[%3p%%] " return table.concat{ setHighlight(statuslineMode), mode, setHighlight(statuslineBlueText), separator, open_file, buf_nr, separator, setHighlight(statuslineTransparent), right_align, setHighlight(statuslineBlueText), separator, file_format, file_type, encoding, setHighlight(statuslineMagentaText), separator, line_no, percentage, separator, } end return M