diff options
| author | Mohammad Reza Karimi <m.r.karimi.j@gmail.com> | 2026-01-21 19:06:11 -0500 |
|---|---|---|
| committer | Mohammad Reza Karimi <m.r.karimi.j@gmail.com> | 2026-01-21 19:06:11 -0500 |
| commit | 6dd62b4cc8b2142135632483bfb55501645d55b8 (patch) | |
| tree | c4cf4b8a2bf34cc578ba83ca81d38363ac55e236 /plugin/plugins/mini.lua | |
| parent | aa5717f00fd14430c80939a68d7107c26de6e554 (diff) | |
big updates
Diffstat (limited to 'plugin/plugins/mini.lua')
| -rw-r--r-- | plugin/plugins/mini.lua | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/plugin/plugins/mini.lua b/plugin/plugins/mini.lua index 24027e0..92f86c6 100644 --- a/plugin/plugins/mini.lua +++ b/plugin/plugins/mini.lua @@ -32,6 +32,98 @@ vim.schedule(function() }) end) +vim.schedule(function() require("mini.icons").setup() end) + +local section_filename = function() + local st = "%{% &busy > 0 ? '◐ ' : '' %}" + -- In terminal always use plain name + if vim.bo.buftype == "terminal" then + return st .. "%t" + elseif _G.MiniStatusline.is_truncated(140) then + -- File name with 'truncate', 'modified', 'readonly' flags + -- Use relative path if truncated + return st .. "%f%m%r" + else + -- Use fullpath if not truncated + return st .. "%F%m%r" + end +end + +local section_git = function() + if _G.MiniStatusline.is_truncated(40) then return "" end + local summary = vim.b.gitsigns_head + if summary == nil then return "" end + return " " .. (summary == "" and "-" or summary) +end + +local section_diff = function() + if _G.MiniStatusline.is_truncated(75) then return "" end + local summary = vim.b.gitsigns_status + if summary == nil then return "" end + return (summary == "" and "-" or summary) +end + +local my_diag_status = function(hl_end) + local diag = vim.diagnostic + local counts = diag.count(0) + local signs = { "E", "W", "I", "H" } + local hl_map = { + [diag.severity.ERROR] = "DiagSLError", + [diag.severity.WARN] = "DiagSLWarn", + [diag.severity.INFO] = "DiagSLInfo", + [diag.severity.HINT] = "DiagSLHint", + } + local result_str = vim.iter(pairs(counts)) + :map( + function(severity, count) + return ("%%#%s#%s:%s"):format( + hl_map[severity], + signs[severity], + count + ) + end + ) + :join(" ") + if result_str:len() > 0 then + result_str = result_str .. "%##%#" .. hl_end .. "#" + end + return result_str +end + +local section_diagnostics = function() + if _G.MiniStatusline.is_truncated(75) then return "" end + if package.loaded["vim.diagnostic"] and #vim.diagnostic.count() ~= 0 then + return my_diag_status("SLDev") + end + return "" +end + vim.schedule(function() - require("mini.icons").setup() + local statusline = require("mini.statusline") + statusline.setup({ + content = { + active = function() + local git = section_git() + local diff = section_diff() + local diagnostics = section_diagnostics() + + local lsp = statusline.section_lsp({ trunc_width = 75 }) + local filename = section_filename() + local fileinfo = vim.bo.filetype + local location = "%-6.(%l,%c%V%) %P" + -- "%{% &ruler ? ( &rulerformat == '' ? '' : &rulerformat ) : '' %}" + + return statusline.combine_groups({ + { hl = "SLFilename", strings = { filename } }, + "%=", -- End left alignment + { hl = "SLDev", strings = { git, diff, diagnostics, lsp } }, + "%<", -- Mark general truncate point + { hl = "SLFileInfo", strings = { fileinfo } }, + { hl = "SLLocation", strings = { location } }, + }) + end, + inactive = nil, + }, + use_icons = true, + }) end) |
