oil.nvim
oil.nvim copied to clipboard
show relative path in window title rather than absolute path
trafficstars
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
show relative path in window title rather than absolute path
I am using floating window. and absolute path for my project is very long and gets truncated in window title it would be better if there is an option to show relative path from current working directory in window title
Provide background
trying to show relative path in window title rather than absolute path when shown in floating mode
What is the significance of this feature?
nice to have
Additional details
No response
With the merged PR (#482) now you can add the following to your config to achieve that:
{
'stevearc/oil.nvim',
opts = {
float = {
get_win_title = function(winid)
local cwd = vim.fn.getcwd()
local buf = vim.api.nvim_win_get_buf(winid)
local file_path = vim.api.nvim_buf_get_name(buf)
local relative_path = file_path:sub(#cwd - 1)
-- leading and trailing spaces just as a personal preference
return ' ' .. relative_path .. ' '
end,
},
},
}
the above code does not work as expected. since file_path is in the format oil:///.....