Skip to content

Commit f6e8b07

Browse files
authored
Show relative paths when CWD only is enabled for recent files (#416)
1 parent 63df284 commit f6e8b07

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lua/dashboard/theme/hyper.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ local function mru_list(config)
187187
local filename = vim.fn.fnamemodify(file, ':t')
188188
local icon, group = utils.get_icon(filename)
189189
icon = icon or ''
190-
if not utils.is_win then
191-
file = file:gsub(vim.env.HOME, '~')
190+
if config.mru.cwd_only then
191+
file = vim.fn.fnamemodify(file, ':.')
192+
elseif not utils.is_win then
193+
file = vim.fn.fnamemodify(file, ':~')
192194
end
193195
file = icon .. ' ' .. file
194196
table.insert(groups, { #icon, group })
@@ -279,8 +281,15 @@ end
279281
local function map_key(config, key, content)
280282
keymap.set('n', key, function()
281283
local text = content or api.nvim_get_current_line()
282-
local scol = utils.is_win and text:find('%w') or text:find('%p')
283-
text = text:sub(scol)
284+
285+
if config.mru.cwd_only then
286+
local scol = text:find(' %w')
287+
text = text:sub(scol)
288+
else
289+
local scol = utils.is_win and text:find('%w') or text:find('%p')
290+
text = text:sub(scol)
291+
end
292+
284293
local path = text:sub(1, text:find('%w(%s+)$'))
285294
path = vim.fs.normalize(path)
286295
if vim.fn.isdirectory(path) == 1 then

0 commit comments

Comments
 (0)