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 local theme = require("statusline.themes.tokyonight") local ns = vim.api.nvim_create_namespace("statusline") function M.output() vim.api.nvim_set_hl_ns(ns) for name, settings in pairs(theme.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(theme.statuslineMode), mode, separator, setHighlight(theme.statuslineBlueText), open_file, buf_nr, separator, setHighlight(theme.statuslineTransparent), right_align, setHighlight(theme.statuslineBlueText), separator, file_format, file_type, encoding, setHighlight(theme.statuslineMagentaText), separator, line_no, percentage, separator, } end return M