Use Relative Path for Filename in Statusline (Multi-Window)? #2056
-
Contributing guidelines
Module(s)mini.statusline QuestionAs mentioned in the title, I would like every window's statusline to have the filename be relative to the PWD; laststatus is set to 2. I've seen #1463, but I already have that behaviour for single windows. The problem lies w/ multiple windows at once. Vim (desired behaviour):
Neovim:Manual
MiniStatusLine.section_filename()
I have tried using both MiniStatusLine.section_filename() and some expansion magic, but to no avail. {
"nvim-mini/mini.statusline",
version = false,
opts = {
use_icons = false,
set_vim_settings = false,
content = {
active = function()
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 512 })
local git = MiniStatusline.section_git({ trunc_width = 75, icon = "" })
local diff = MiniStatusline.section_diff({ trunc_width = 75, icon = "" })
local diagnostics = MiniStatusline.section_diagnostics({
trunc_width = 75,
icon = "",
signs = { ERROR = "!", WARN = "?", INFO = "@", HINT = "*" },
})
-- TODO: Get name w.r.t PWD
local pathname = vim.bo.buftype == "terminal" and "%t"
or "%#MiniStatuslineFilename#" .. vim.fn.expand("%:t") .. (vim.bo.modified and " [+]" or "")
local fpath
fpath = MiniStatusline.section_filename({ trunc_width = 512 })
fpath = pathname
---
local devinfo
if git == "" then
devinfo = diff == " -" and "" or diff
else
devinfo = git .. (diff == " -" and " " or (" │" .. diff))
end
return MiniStatusline.combine_groups({
{ hl = mode_hl, strings = { mode } },
{ hl = "MiniStatuslineDevinfo", strings = { diagnostics } },
"%<", -- Mark general truncate point
{ hl = "MiniStatuslineFilename", strings = { fpath } },
"%=", -- End left alignment
{ hl = "MiniStatuslineDevinfo", strings = { devinfo } },
{ hl = mode_hl, strings = { "%-2l,%-2v" } },
})
end,
},
},
},
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Content for not current (i.e. "active") windows is configured via So something like this: require('mini.statusline').setup({
content = {
active = function()
-- Your content for active window
end,
inactive = function() return '%f' end,
},
}) |
Beta Was this translation helpful? Give feedback.
-
|
Perfect; many thanks. |
Beta Was this translation helpful? Give feedback.



Content for not current (i.e. "active") windows is configured via
config.content.inactivefunction. Use%fto make content show relative file path (see:h 'statusline').So something like this: